Results 1 to 3 of 3

VBA Vlookup row and column variables

Threaded View

  1. #1
    Registered User
    Join Date
    11-20-2008
    Location
    Melbourne, Australia
    MS-Off Ver
    Office 2007 Professional
    Posts
    20

    VBA Vlookup row and column variables

    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???
    Last edited by rylo; 11-20-2008 at 08:27 PM. Reason: add code tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1