remove #NA from VLookup macro result...?

blist

New Member
Joined
Mar 11, 2004
Messages
20
My Lookup value range contains many blank cells I'd like to remain blank. This code works to populate that range as needed, but the blank cells all show a #NA result. How can I edit this (or another?) macro to leave the blank cells empty?

Code:
Sub EQL_Lookup()
Dim LastRow As Long
LastRow = Range("A" & Rows.Count).End(xlUp).Row

With WorksheetFunction

     Range("L2:P" & LastRow).Value = .VLookup(Range("L2:P" & LastRow), Sheets(13).Range("A1:C" & LastRow), 2, False)
    
End With
End Sub
 
Jeffery Smith, same result as last, Sub or function not defined at the red text

Code:
Sub EQL_Lookup()
Dim LastRow As Long
Dim V As Variant
LastRow = Range("A" & Rows.Count).End(xlUp).Row
  With WorksheetFunction
    On Error GoTo NoVal
    Range("L2:P" & LastRow).Value = .VLookup(Range("L2:P" & LastRow), Sheets(13).Range("A1:C" & LastRow), 2, False)
  End With
Exit Sub
: [highlight]NoVal[/highlight]
Range("L2:P" & LastRow).Value = ""
Resume Next
End Sub
 
Last edited:
Upvote 0

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Forum statistics

Threads
1,224,522
Messages
6,179,297
Members
452,903
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top