I am using below code to add a column named "Roles".
If WorksheetFunction.CountIf(rngX, "Roles") > 0 Then
MsgBox "Roles column Already present"
Else
ESheet.Columns("C:C").Insert Shift:=xlToRight,CopyOrigin:=xlFormatLeftOrAbove
ESheet.Range("C1").Value = "Roles"
LastRow1=ESheet.Range("A", & Cells.Rows.Count).End(xlUp).Row
ESheet.Range("C2:C", & LastRow1).Formula="VLOOKUP(B2, Roles!$A:$B,2,FALSE)"
End IF
I am trying this code, There is a Roles sheet which I am referring for vlookup and adding new column named "Roles" in new tab "Titles". If column is already there, it shows msgbox but changes Vlookup values -- vlookup(B2, #Ref!$A:$B,2,FALSE)
Basically i want to remove this vlookup error so that it keeps referring Roles tab