PDA

View Full Version : Solved: VLOOKUP



justdriving
09-09-2011, 02:31 PM
Hi,

I know how to use VLOOKUP function in EXCEL.
I am looking to learn that how I can use it in VBA as

(1) Worksheetfunction
or
(2) UDF


For example,
A25:A50 contains ProductID
B25:B50 contains ProductName

How can I use VLOOKUP or similar function in VBA to find ProductName, if I have ProductID available?

Bob Phillips
09-09-2011, 04:53 PM
Dim cell As Range

On Error Resume Next
Set cell = Range("A25:A50").Find("productid")
On Error GoTo 0
If Not cell Is Nothing Then

MsgBox cell.Offset(0, 1).Value2
End If

justdriving
09-09-2011, 06:42 PM
Thanks. It solved this problem.