Results 1 to 10 of 10

Range for Vlookup: refer to columns stored in a variable

Threaded View

stefy1984 Range for Vlookup: refer to... 07-09-2012, 12:43 PM
Xer2 Re: Range for Vlookup: refer... 07-09-2012, 12:54 PM
stefy1984 Re: Range for Vlookup: refer... 07-10-2012, 03:25 AM
Xer2 Re: Range for Vlookup: refer... 07-10-2012, 11:24 AM
stefy1984 Re: Range for Vlookup: refer... 07-10-2012, 03:15 PM
Xer2 Re: Range for Vlookup: refer... 07-10-2012, 04:21 PM
stefy1984 Re: Range for Vlookup: refer... 07-10-2012, 04:48 PM
Xer2 Re: Range for Vlookup: refer... 07-10-2012, 05:10 PM
stefy1984 Re: Range for Vlookup: refer... 07-10-2012, 06:16 PM
Xer2 Re: Range for Vlookup: refer... 07-10-2012, 06:24 PM
  1. #1
    Registered User
    Join Date
    07-09-2012
    Location
    netherlands
    MS-Off Ver
    Excel 2010
    Posts
    5

    Range for Vlookup: refer to columns stored in a variable

    Hi,
    I’m new in the VBA world and in this forum. I’m trying to do a vlookup but I’m facing a problem
    I need to refer to a range in another worksheet. The columns to which I want to refer can vary position. Therefore I get their column number and store it in a variable (ColC, ColN)
    I don’t know how to refer to the range. If I refer to the range by the letter of the columns, the vlookup works.

    Cells(i, 2).Value = Application.WorksheetFunction.VLookup(Cells(i, 1).Value, Sheets("S1").Columns("B:E"), ColVLU, False)
    However these columns can move and I need to find a way to refer to this range without using (“B:E”).
    I’ve tried this but it doesn’t work

    Cells(i, 2).Value = Application.WorksheetFunction.VLookup(Cells(i, 1).Value, Sheets("S1").Range(Columns(ColC), Columns(ColN), ColVLU, False)
    Any suggestion? Thanks a lot for the help!
    Last edited by Cutter; 07-10-2012 at 04:28 PM. Reason: Added code tags

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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