Index Match function in excel vba with 3 different comparison

Joined
Feb 17, 2016
Messages
2
Hello,
I want to compare 2 logic in 2 different work sheets at same time if 2 logic is true then output will be shown.

I have written vba code for the same using IF logic, it is working but it takes too much time for running.
Hence i tried to change IF logic to INDEX MATCH function vba code, but it is not working it shown syntax error.
I attach my both IF logic and INDEX MATCH code for your reference. Please help me to solve this issue.

Logics:
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;">Sheet1 = Active sheet
Sheet2
= PDMS EXTRACT
If sheet1->"/" & "B2" & "-X" = sheet2->A2 then
If sheet2->B2 = "SUBE" then
sheet1 D2
= sheet2 E2 'output
</code>

<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;">Vba code using IF logic:

<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;">ActiveWorkbook.ActiveSheet.Select



For i = 3 To 1000 'offline inst elevation



For n = 2 To 5000



If "/" & ActiveSheet.Cells(i, "B") & "-X" = Sheets("PDMS EXTRACT").Cells(n, "A") Or "/" & ActiveSheet.Cells(i, "B") = Sheets("PDMS EXTRACT").Cells(n, "A") Then


If Sheets("PDMS EXTRACT").Cells(n, "B") = "SUBE" Then



ActiveSheet
.Cells(i, "D") = Sheets("PDMS EXTRACT").Cells(n, "E")



End If
End If
Next n
Next i
'......it's working fine but running time to slow.
</code>
</code>
</pre>
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;">
Vba code using INDEX MATCH:

<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;">ActiveSheet.Cells(i, "D") = Application.WorksheetFunction.Index(Sheets("PDMS EXTRACT").Range("A:E"), Application.WorksheetFunction.Match(1, ("/" & ActiveSheet.Cells(i, "B") & "-X" = Sheets("PDMS EXTRACT").Range("A:A")) * ("SUBE" = Sheets("PDMS EXTRACT").Range("B:B")), 0), 5) </code>but this code is not working, please check the code and tell me the proper code to execute this.
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;"></code></pre>
</code></pre>
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Forum statistics

Threads
1,223,911
Messages
6,175,327
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top