Announcement

Collapse
No announcement yet.

Pass a variable to Vlookup

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Pass a variable to Vlookup



    I am sure this is simple but can't get this to work. I am trying to create VBA code so that the user can enter a cell Column and Row via an Input Box and this variable will be passed to the Vlookup formula. UCI is the location of the starting cell, for example D8. When this runs it returns =VLOOKUP(UCI, Clientlist.xls!$A$2:$F$24216,5,FALSE).

    [code]
    Sub Macro3()

    Dim UCI As String
    UCI = InputBox("Enter Cell location for first UCI Number Field")
    ActiveCell.FormulaR1C1 = _
    "=VLOOKUP(UCI, Clientlist.xls!R2C1:R24216C6,5,FALSE)"

    End Sub
    [\code]

    Any help is appreciated. Thanks

    Peter

  • #2


    Hello,

    You can test following :

    Code:
    Sub Macro4()
    Dim UCI As String
    UCI = InputBox("Enter Cell location for first UCI Number Field")
    ActiveCell.Formula = "=VLOOKUP(" & UCI & ", Clientlist.xls!$A$2:$F$24216,5,FALSE)"
    End Sub
    Hope this will help
    If you feel like saying "Thank You" for the help received ...You can click on the "Like" icon ...just underneath ... ... in the bottom right corner ...

    Comment

    Working...
    X