I am trying to do a vlookup on my Excel spreadsheet using the following VBA code:
Dim row As Integer
Dim prodCodeCol As String
Dim weightCol As String
row = 2
prodCodeCol = "O"
weightCol = "J"
Range(weightCol & row).Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(" & prodCodeCol & row & ",'[Kogan WMS 1.1.xls]Stock Profile'!C1:C11,8, FALSE)"
However when I run the macro the following formula ends up in cell J2 :
=VLOOKUP('o2','[Products 1.1.xls]Stock Profile'!$A:$K,8, FALSE)
The formula is correct except for the apostrophes ' ' around o2.
How can I make it so there there are not any apostrophes around o2 so that it references the cell o2???
Bookmarks