Vlookup with sheet names stored in array

Syaza Azman

New Member
Joined
May 16, 2018
Messages
3
Hi,
i'm trying to vlookup some comments from a different workbook with its sheets names stored in array.

i have two problems here.

1. The first vlookup runs without an error, but i didnt get any results
2. The second vlookup gives error 1004 ; apllication-defined or object-defined error

Code:
For Each TabName In Array("report", "Pending", "Created")
        
        On Error GoTo NextTabName8
                      
            If TabName = "report" Then
            
                VLatCell = "T3"
                AutoFillIndicator = "R3"
                
                Windows("Work_Order_Report__Weekly_Repo.xlsx").Activate
                Sheets(TabName).Select
                Range("T1").Value = TabName
                Range(VLatCell).Select
                ActiveCell.FormulaR1C1 = _
                    "=VLOOKUP(RC[-5],'[Work Order Report - 8 Week.xlsx]" & "TabName" & "'!C15:C20,6,0)"
                    
                Range(AutoFillIndicator).Select
                Selection.End(xlDown).Select
                ActiveCell.Offset(0, 2).Select
                Range(Selection, "T3").Select
                Selection.FillDown
            
            Else
            
            
                VLatCell = "S2"
                AutoFillIndicator = "R2"
                
                        
                Windows("Work_Order_Report__Weekly_Repo.xlsx").Activate
                Sheets(TabName).Select
                Range(VLatCell).Select
                ActiveCell.FormulaR1C1 = _
                    "=VLOOKUP(RC[-4],'[Work Order Report - 8 Week.xlsx]" & "TabName" & "'!C15:C19,5,0)"
                    
                Range(AutoFillIndicator).Select
                Selection.End(xlDown).Select
                ActiveCell.Offset(0, 2).Select
                Range(Selection, "S2").Select
                Selection.FillDown
        
            End If


NextTabName8:
Next TabName
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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