How to use lookup Function in vba

Z

ZarrinPour

Hi
I have write the following Line in "Worksheet_Change" event

///////////////////////////////////////////////////////////////////////////////////////
Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False

lookup_value =
Sheet1.Application.WorksheetFunction.Lookup(Target.Value, A2:A5,
B2:B5)


Application.EnableEvents = True

End Sub
///////////////////////////////////////////////////////////////////////////////////////

but all the time i recieve the following Error from the compiler.
---------------------------
Microsoft Visual Basic
---------------------------
Compile error:

Expected: list separator or )
---------------------------
OK Help
---------------------------

Am i doing something wrong? Please help me.

Thanks in advance.
Regards.
 
B

Bob Phillips

Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False

lookup_value = _
Sheet1.Application.WorksheetFunction.Lookup(Target.Value,
Range("A2:A5"),Range("B2:B5"))
Application.EnableEvents = True

End Sub


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top