+ Reply to Thread
Results 1 to 3 of 3

vlookup with variable range and variable array size

Hybrid View

  1. #1
    Registered User
    Join Date
    01-15-2013
    Location
    London, england
    MS-Off Ver
    Excel 2003
    Posts
    2

    vlookup with variable range and variable array size

    Hi,

    I'm having real trouble with VBA. I want to search a table for values in column A and return the values in colum d.

    The values in A are changing through the chart.

    This is what i have as a test and all I get is it entering the formula and not putting the values called out in the set statments.

    Dim c As Integer
    Dim b As Integer
    c = 4
    b = 2
    Dim lookin As Range
    Dim lookfor As Range
    Set lookin = Range("a1:G4")
    Set lookfor = Range("A" & CStr(b))
        ActiveCell.Formula = "=VLOOKUP(lookfor,lookin,4,TRUE)"
    I would like to be able to have A1:g4 as a variable and b will be cycling....

    any ideas?
    Last edited by vlady; 01-15-2013 at 07:35 PM. Reason: code tags

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: vlookup with variable range and variable array size

    Hi

    try something like

    activecell.value = evaluate("=vlookup(" & lookfor.address & "," & lookin.address & ",4,true)")
    rylo

  3. #3
    Registered User
    Join Date
    01-15-2013
    Location
    London, england
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: vlookup with variable range and variable array size

    thanks rylo. Much appreciated.

+ Reply to Thread

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