In place of: ActiveCell.FormulaR1C1 use: ActiveCell.Formula change other part of formula accordingly.
Akhilesh On Fri, Nov 21, 2008 at 8:56 AM, Leigh Williams <[EMAIL PROTECTED]>wrote: > > 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??? > > > > --~--~---------~--~----~------------~-------~--~----~ Visit the blog to download Excel tutorials at http://www.excel-macros.blogspot.com To post to this group, send email to excel-macros@googlegroups.com For more options, visit this group at http://groups.google.com/group/excel-macros?hl=en Visit & Join Our Orkut Community at http://www.orkut.com/Community.aspx?cmm=22913620 Visit the blog to download Excel tutorials at http://www.excel-macros.blogspot.com To Learn VBA Macros Please visit http://www.vbamacros.blogspot.com To see the Daily Excel Tips, Go to: http://exceldailytip.blogspot.com -~----------~----~----~----~------~----~------~--~---