+ Reply to Thread
Results 1 to 2 of 2

Macro to write Vlookup formula with variable column index

  1. #1
    Registered User
    Join Date
    08-08-2012
    Location
    UAE
    MS-Off Ver
    Excel 2007
    Posts
    43

    Macro to write Vlookup formula with variable column index

    Hi Guys,

    I have defined the following dependent on a dynamic range:

    a = ActiveCell.Column
    I need the column index in the below vlookup formula to refer to the value of a, but it literally enters

    =+IFERROR(VLOOKUP(D13,'[IBC Daily Reported Date 08112012.xlsx]IBC'!$A:$G,a,0),"") as the formula in the cell. How do I need to change this reference???

    Please Login or Register  to view this content.

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Macro to write Vlookup formula with variable column index

    Try the following:
    Please Login or Register  to view this content.
    In your code, you placed the "a" with the double quotes of the formula so this is what you get. Butyou really want to put the value of your variable "a" into the formula. That is what the concatenation will do.
    Pierre Leclerc
    _______________________________________________________

    If you like the help you got,
    Click on the STAR "Add reputation" icon at the bottom.

+ 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