VLOOKUP as a vb code

  • Thread starter Thread starter Tdp
  • Start date Start date
T

Tdp

How do I change the following as a vb code???
=VLOOKUP(AZ4,Sheet3!A:B,2,0)
 
Try this:

x = Application.WorksheetFunction.VLookup(Range("AZ4"), Sheet3.Range("A:B"),
2, 0)

Regards,
Per
 
Just one more question Per
With this code how do I include if the cell is empty then show zero?
 
Hi Tdp

As you don't write which cell could be empty I assume that it's AZ4.

If Range("AZ4").Value = "" Then
x = 0
Else
x = Application.WorksheetFunction.VLookup(Range("AZ4"),
Sheet3.Range("A:B"), 2, 0)
End If

Regards,
Per
 
Sorry about that.......I forgot.
It works well now. I only made one change to it

If Range("AZ14").Value = "" Then
Range("BB14").Value = ""
Else
Range("BB14").Value =
Application.WorksheetFunction.VLookup(Range("AZ14"), Sheet3.Range("A:B"), 2,
0)
End If

Many thanks
 

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

Back
Top