+ Reply to Thread
Results 1 to 4 of 4

How to define table array in Vlookup function using VBA?

  1. #1

    How to define table array in Vlookup function using VBA?

    there's one integer variable, j.
    I want to use VLookup function here, and the table Array parameter
    should be Column j to j+1
    But how to write this code in VBA?
    Application.VLookUp(Cells(1,1), COLUMNS(j,j+1), 2 FALSE) ???
    It report erros like above.
    Thanks.


  2. #2
    Registered User
    Join Date
    12-09-2003
    Posts
    12

    Cheat? Put the value in an un-used cell?

    If you set up a Vlookup function in the spreadsheet...(un-used cell)

    and identify a cell to paste the lookup value... (lookup function first term)

    you can use Excel to do the lookup and then just "get" the value from the function cell...

    something like:

    Cells(1,1)="MyValue"
    Return_value=cells(1,2)

    where the lookup value is in cell(1,1) and the lookup formula is in cell(1,2)...

  3. #3
    Bob Phillips
    Guest

    Re: How to define table array in Vlookup function using VBA?

    Try

    Application.VLookUp(Cells(1,1), COLUMNS(j).Resize(,2), 2 FALSE)

    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    <[email protected]> wrote in message
    news:[email protected]...
    > there's one integer variable, j.
    > I want to use VLookup function here, and the table Array parameter
    > should be Column j to j+1
    > But how to write this code in VBA?
    > Application.VLookUp(Cells(1,1), COLUMNS(j,j+1), 2 FALSE) ???
    > It report erros like above.
    > Thanks.
    >




  4. #4

    Re: How to define table array in Vlookup function using VBA?

    Thanks Bob, it works!
    appreciated

    Bob Phillips =E5=86=99=E9=81=93=EF=BC=9A

    > Try
    >
    > Application.VLookUp(Cells(1,1), COLUMNS(j).Resize(,2), 2 FALSE)
    >
    > --
    > HTH
    >
    > Bob Phillips
    >
    > (remove nothere from email address if mailing direct)
    >
    > <[email protected]> wrote in message
    > news:[email protected]...
    > > there's one integer variable, j.
    > > I want to use VLookup function here, and the table Array parameter
    > > should be Column j to j+1
    > > But how to write this code in VBA?
    > > Application.VLookUp(Cells(1,1), COLUMNS(j,j+1), 2 FALSE) ???
    > > It report erros like above.
    > > Thanks.
    > >



+ 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