Index Match Function to VBA

nhinx

New Member
Joined
Aug 25, 2016
Messages
40
Office Version
  1. 2010
Hello,



Would like to ask your help to convert the below function to VBA.



=INDEX('Sheet 1'!A:A,MATCH(1,('Sheet 1'!B1:B90200='Sheet 2'!B3)*('Sheet 1'!C1:C90200='Sheet 2'!C3)*('Sheet 1'!D1:D90200='Sheet 2'!D3)*('Sheet 1'!E1:E90200='Sheet 2'!E3),0))

=INDEX('Sheet 1'!A:A,MATCH(1,('Sheet 1'!B1:B90200='Sheet 2'!B4)*('Sheet 1'!C1:C90200='Sheet 2'!C4)*('Sheet 1'!D1:D90200='Sheet 2'!D4)*('Sheet 1'!E1:E90200='Sheet 2'!E4),0))

=INDEX('Sheet 1'!A:A,MATCH(1,('Sheet 1'!B1:B90200='Sheet 2'!B5)*('Sheet 1'!C1:C90200='Sheet 2'!C5)*('Sheet 1'!D1:D90200='Sheet 2'!D5)*('Sheet 1'!E1:E90200='Sheet 2'!E5),0))



which will populate up to rows 90,200



Thank you
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
VBA Code:
Sub IndexMatch()
    For i = 3 To 90200
        Sheets("Destination").Range("A" & i).Formula = "=INDEX('Sheet 1'!A:A,MATCH(1,('Sheet 1'!B1:B90200='Sheet 2'!B" & i & ")*('Sheet 1'!C1:C90200='Sheet 2'!C" & i & ")*('Sheet 1'!D1:D90200='Sheet 2'!D" & i & ")*('Sheet 1'!E1:E90200='Sheet 2'!E" & i & "),0))"
    Next i
End Sub
 
Upvote 0
Solution
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
VBA Code:
Sub IndexMatch()
    For i = 3 To 90200
        Sheets("Destination").Range("A" & i).Formula = "=INDEX('Sheet 1'!A:A,MATCH(1,('Sheet 1'!B1:B90200='Sheet 2'!B" & i & ")*('Sheet 1'!C1:C90200='Sheet 2'!C" & i & ")*('Sheet 1'!D1:D90200='Sheet 2'!D" & i & ")*('Sheet 1'!E1:E90200='Sheet 2'!E" & i & "),0))"
    Next i
End Sub
Thank you iggydarsa for the code. However, the value came out #N/A. How will I activate the formula without doing the CTRL+SHIFT+ENTER?
 
Upvote 0
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
Thanks for the info.
 
Upvote 0
Thank you iggydarsa for the code. However, the value came out #N/A. How will I activate the formula without doing the CTRL+SHIFT+ENTER?
I got it already. I just changed the word Formula to FormulaArray
 
Upvote 0

Forum statistics

Threads
1,215,577
Messages
6,125,637
Members
449,242
Latest member
Mari_mariou

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