Vba: Application.VLookup doesn't work with numeric values (error 2042)

Nelson78

Well-known Member
Joined
Sep 11, 2017
Messages
526
Office Version
  1. 2007
Hello everybody.

I have:

VBA Code:
For Each cell In sheets(1).Range("E2:E" & len)
                    result1 = Application.VLookup(cell, rng1, 3, False)
                    result2 = Application.VLookup(cell, rng1, 17, False)
                    result3 = Application.VLookup(cell, rng1, 18, False)
Next cell

The value of cell can be:
1) Alphanumeric: in this case no problem;
2) Numeric: in this case result1, result2 and result3 are not calculated (error 2042).

Could you help me?

Thank's.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
VLOOKUP will work for either alphanumeric or numeric values.
The restriction is the values you are matching on MUST be the exact same format/data type.
Match only works when matching on:
- numeric entries matching to other numeric entries
- string/text entries matching to other string/text entries

If you try to match a numeric entry to a "number entered as text" (usually evident by the entry being left-justified in the cell), it will NOT work.
This is the single biggest issue people have with VLOOKUP, trying to compare different data types. You need to standardize the data first.
 
Upvote 1
Solution

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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