I am having two Sheets BW and PSW.
With the BW the data is starting from row 4. the above 3 rows are merged and I have some command Buttons there. the sheet PSW starts from 1st row.
I am looking for the ID in sheet1,which starts from L5 and when the Id matches in sheet2, it pulls the date from sheet2 to sheet1. I am using the below code. The code, is not executing any Output. Could anyone tell where I am making mistake.
I suppose,in the below line, the range starts from A and since my data starts from row5, it does not Count. if this is the case, then how i should Change the range. I had this code running, if my data starts with row1 without any command buttons.
totalrows = Sheets("BW").Cells(Rows.Count, "A").End(xlUp).Row
Sub lookupePSR()
Dim totalrows As Long, totalrowsSht2 As Long
totalrows = Sheets("PSW").Cells(Rows.Count, "A").End(xlUp).Row
totalrowsSht2 = Sheets("PSW").Cells(Rows.Count, "A").End(xlUp).Row
Sheets("PSW").Range("AA5:AA" & totalrows).Formula = Application.WorksheetFunction.IfError(Application.VLookup(Sheets("PSW").Range("L5:L" & totalrowsSht2), Sheets("PSW").Range("$A:$L"), 7, 0), "")
End Sub
Sheets("PSW").Range("AA5:AA" & totalrows).Formula = "PUT ACTUAL FORMULA HERE"
Put the formula in the worksheet and then put it in the code that I gave. Replace all"
, if any, with""
– Siddharth RoutAA5
and then use that. If it doesn't work then post the formula that you manually put inAA5
– Siddharth Rout