Consulting

Results 1 to 3 of 3

Thread: reference myinput in vlookup formula

  1. #1
    VBAX Regular
    Joined
    May 2007
    Posts
    72
    Location

    reference myinput in vlookup formula

    hi there -

    this is my first time posting a thread, but i've been an avid visitor to this site as its SUPER HELPFUL. I'm attempting to include in vba a vlookup formula which needs to reference the lookup range to a different tab name every week.

    I want there to be a user prompt which requests the week number and then uses that week number in the vlookup formula as the tab name. Below is what I currently have, but it bugs out on me every time.

    Dim MyInput

    MyInput = InputBox("Enter PLans tab name")

    Range("Y2").Select
    ActiveCell.FormulaR1C1 = _
    "=IF(ISERROR(VLOOKUP(RC17,'[PLan.xls] & MyInput & "'!R2C22:R1022C36),4,FALSE)),0,(VLOOKUP(RC17,indirect("'[PLan.xls] & MyInput & "'!R2C22:R1022C36)'!R2C22:R1022C36,4,FALSE)))"

    Any help would be greatly appreciated...

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Dim MyInput
    Dim sFormula As String

    MyInput = InputBox("Enter PLans tab name")

    sFormula = "=IF(ISERROR(VLOOKUP(RC17,'[PLans.xls]" & MyInput & "'!R2C22:R1022C36,4,FALSE)),0," & _
    "VLOOKUP(RC17,'[PLans.xls]" & MyInput & "'!R2C22:R1022C36,4,FALSE))"
    Range("Y2").FormulaR1C1 = sFormula
    [/vba]

  3. #3
    VBAX Regular
    Joined
    May 2007
    Posts
    72
    Location
    THANK YOU THANK YOU THANK YOU!

Posting Permissions

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