Hi! I have two spreadsheets (A and B) and I'd like VBA to do a VLOOKUP from A to B.
Once the ranges are dynamic, I defined counters and they are working, I checked that.
So there's the loop, contador stands for the counter in spreadsheet A. It should look for the content of cell Y&counter in spreadsheet B, from A1 to Cells( counter3, 4) and return me the fourth column match back in spreadsheet A, cell R&counter. Unfortunatelly it displays error message 1004 "definition of application or object definition error".
I tried using both Application.WorksheetFunction.Vlookup [...] and just Application.Vlookup [...], same error. The fourth argument of VLOOKUP being true, false or absent, same error.
Once the ranges are dynamic, I defined counters and they are working, I checked that.
So there's the loop, contador stands for the counter in spreadsheet A. It should look for the content of cell Y&counter in spreadsheet B, from A1 to Cells( counter3, 4) and return me the fourth column match back in spreadsheet A, cell R&counter. Unfortunatelly it displays error message 1004 "definition of application or object definition error".
VBA Code:
Do While contador < Linhas2 + 1
ActiveSheet.Range("R" & contador).Value = Application.VLookup(Range("Y" & contador), Workbooks("ME2M - FUP Atual.mhtml").Sheets("Sheet1").Range(Cells(1, 1), Cells(Linhas, 4)), 4)
contador = contador + 1
Loop
I tried using both Application.WorksheetFunction.Vlookup [...] and just Application.Vlookup [...], same error. The fourth argument of VLOOKUP being true, false or absent, same error.