(Solved) – How do you use VLOOKUP with a loop in Excel VBA to write data into multiple sheets?


Im trying to write information onto multiple sheets in excel using loops and VLookup, that all get their information from the same Input sheet. It works perfectly for one sheet, but I keep getting an error that it’s “Unable to get the VLookup property of the Worksheet Function class” for the other sheets. The error is in variable Wave(i).
**My Code is below **

||Function Waves(BN() As Integer, Table As Range, Wave() As String, wsName As String, _

numRows As Integer)
Dim i As Integer
For i = 0 To numRows
BN(i) = ThisWorkbook.Worksheets(wsName).Range(“A” & i 2) ‘change 5k to a string variable
Set Table = ThisWorkbook.Worksheets(“Cleaned Input”).Range(“Table2”)
Wave(i) = Application.WorksheetFunction.VLookup(BN(i), Table, 13)
ThisWorkbook.Worksheets(wsName).Range(“F” & i 2) = Wave(i)
End Function||

Leave a Reply

Your email address will not be published. Required fields are marked *