Forum Discussion
NRASA0743
Jul 20, 2022Copper Contributor
VBAVlookup
Trying to macro Vlookup with a user prompt to manually select range and type columm number, but the code is not working, what am I doing wrong? Sub VbaVlookup()
Dim Table As Range
Dim Colnum As Int...
- Jul 20, 2022
Sub VbaVlookup() Dim Table As Range Dim Colnum As Integer On Error Resume Next Set Table = Application.InputBox(Prompt:="Sample", Type:=8) Colnum = Application.InputBox(promt:="Sample", Type:=1) Selection.Formula = "=VLOOKUP(A2," & Table.Address(External:=True) & "," & Colnum & ",FALSE)" End Sub
NRASA0743
Jul 20, 2022Copper Contributor
HansVogelaar how do I get the final result as a vlookup formula. The code above it will paste the result as value. Tried replacing Selection.Value with Selection Formula didn't work.
HansVogelaar
Jul 20, 2022MVP
Sub VbaVlookup()
Dim Table As Range
Dim Colnum As Integer
On Error Resume Next
Set Table = Application.InputBox(Prompt:="Sample", Type:=8)
Colnum = Application.InputBox(promt:="Sample", Type:=1)
Selection.Formula = "=VLOOKUP(A2," & Table.Address(External:=True) & "," & Colnum & ",FALSE)"
End Sub
- NRASA0743Jul 21, 2022Copper ContributorWow thanks yoy are awesome