I am very new to VBA, I have a formula with me, Which I want in Macro.
I used Macro recording to have the vba, but the Problem is it is generating for each row, making the vba code complex. also, it Displays the formula in formula bar. I have two Sheets , sheet 1 (BW) and sheet2(CW). I want the code in sheet 1. it Looks for ID in sheet 2 and copy the values from Ad to Au of sheet1.
I have tried, to some extent to implement my formula to code.
=IF(IFERROR(VLOOKUP($B2;CW!$B$2:$AU591;30;FALSE);"0")=0;" ";IFERROR(VLOOKUP($B2;CW!$B$2:$AU591;30;FALSE);""))
Sub lookupo()
Dim totalrows As Long
Dim totalrowssh2 As Long
totalrows = Sheets("BW").Cells(Rows.Count, "A").End(xlUp).Row
totalrowsSht2 = Sheets("CW").Cells(Rows.Count, "A").End(xlUp).Row
sheets("BW").Range("AD2:AD" & Totalrows).formula = Application.WorksheetFunction.If(Iferror(Apllication.Vlookup(sheets("BW").Range("B2:B" &totalrowssht2), Sheets("CW").Range("$A:$AU"),29,False),"0"))=0,"")
End Sub
I am struck how i should implement the second formula in line. Could someone help me to overcome with a VBA code.
totalrowssh2
/totalrowsSht2
.Option Explicit
at the top of each module points these errors out. – Darren Bartrup-Cook