Error in VLookup

macro_user

Board Regular
Joined
Mar 9, 2009
Messages
101
hi...
i have a doubt regarding VLookup... when would i get #N/A and when would i get #VALUE! ??? i dont know how to differentiate between these 2 errors....
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Hi,

An N/A suggests that there is no match, a value error would suggest a problem with the formula. Care to post the formula thats causing issue?
 
Upvote 0
Code:
thisworkbook.sheets("Sheet1").activate
lastrow_in_Col_A = range("A65536").End(xlUp).row
    With range("G4:G" & lastrow_in_Col_A)
    .Formula = "=VLOOKUP(F4,'Sheet2'!F:G,2,FALSE)"
    .value = .value
    End With

out of 800 values, 200 values are #N/A and 5 are #VALUE! ... the rest of the values are getting populated from the VLookup formula...
 
Upvote 0
Hi,

I'd suggest;

Code:
Dim lRow As Long

lRow = Range("A" & Rows.count).End(xlUp).Row

Range("G4:G" & lRow) = Application.VLookup(Range("F4:F" & lRow), Sheets("Sheet2").Columns("F:G"), 2, 0)
 
Upvote 0
ya i would try this... thank you... but can you tell me wat could've been the error in the previous code and how this piece of code would work better than tat... i need to give an explanation for the change in code... tats why.. Thanx in advance...
 
Upvote 0
hi...
i tried the one which u told me to and still i get the same results... the data for which i get #VALUE! , i dont have the corresponding data to fetch for the VLookup... tats why i get an error... tats fine but i dont understand why i get #N/A seperately and #VALUE! seperately for the same reason...
 
Upvote 0
Hi,

Can you possibly post a few examples of each result and hopefully I'll be able to explain why. I should imagine you will find that my method on the VLOOKUP slightly more efficient over a large number of formula, they are however doing very much the same thing.
 
Upvote 0
hi...
when i looked at the values for which i was doing a VLookup, there was 1 value which was very long, almost 75 characters in length(which dint have a value from the VLookup) for which i got #VALUE!... so would tat be a reason??? bcoz for only tat value i get #VALUE! and for the others which dont have a value, i get #N/A...
 
Upvote 0
Hi,

I guess thats a possibility, not sure what the character limit is on the Lookup Value of a Lookup.
 
Upvote 0

Forum statistics

Threads
1,214,812
Messages
6,121,693
Members
449,048
Latest member
81jamesacct

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