Index Match formulas with generic sheets

Apple08

Active Member
Joined
Nov 1, 2014
Messages
450
Hi All

I have created index match formulas below and I need to make the worksheets name generic, Sheets(2) and Sheets(3). The macro below doesn't work, could anyone help me please? I am not sure is it the right way to make worksheet name generic. Thanks.

VBA Code:
[SIZE=4][FONT=Segoe UI][COLOR=rgb(20, 20, 20)]Sheets(3).Select



Dim LastRow As Long

  

LastRow = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row



    Range("O25").FormulaArray = "=iferror(index(Sheets(2)!$C$15:$AZ$15,match(Sheets(3)!$B25,Sheets(2)!$C$10:$AZ$10,0)),"""")" & _

        ""

    Range("P25").FormulaArray = "=iferror(index(Sheets(2)!$C$35:$AZ$35,match(Sheets(3)!$B25,Sheets(2)!$C$10:$AZ$10,0)),"""")" & _

        ""

    Range("Q25").FormulaArray = "=iferror(index(Sheets(2)!$C$37:$AZ$37,match(Sheets(3)!$B25,Sheets(2)!$C$10:$AZ$10,0)),"""")" & _

        ""

    Range("R25").FormulaArray = "=iferror(index(Sheets(2)!$C$39:$AZ$39,match(Sheets(3)!$B25,Sheets(2)!$C$10:$AZ$10,0)),"""")" & _

        ""

    Range("O25:J" & LastRow).FillDown

    Range("P25:P" & LastRow).FillDown

    Range("Q25:Q" & LastRow).FillDown

    Range("R25:R" & LastRow).FillDown

End Sub[/COLOR][/FONT][/SIZE]
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Saying that code does not work means very little without additional clarification. There is a big difference between 'doesn't work' and 'doesn't work as expected'

If you mean that you want to use the vba sheet index in place of the actual sheet name then you would need to use

"=IFERROR(INDEX(" & Sheets(2).Name & "!$C$15:$AZ$15"
 
Upvote 0

Forum statistics

Threads
1,214,990
Messages
6,122,626
Members
449,093
Latest member
catterz66

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