Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

excel vlookup left

Forum home » Delegate support and help forum » Microsoft Excel Training and help » Excel - vlookup with left & find not working

Excel - vlookup with left & find not working

ResolvedVersion 2010

Christopher has attended:
Excel Advanced course
Excel Advanced - Formulas & Functions course
Excel VBA Introduction course

Excel - vlookup with left & find not working

HI all,

I'm trying to write a function to pick up the first part of a postcode (the bit before the space) and assign it a region so that new postcodes with be assigned that region.

I built a table with region in column 1 and the 1st section of the postcode a in column 2. I formatted as a table in Excel (called "Table1" - as this is just a test).

In my main data I used the following to pick-up the 1st section of the postcode and use a lookup to assign the region.

=VLOOKUP(LEFT(E2,FIND(" ",E2,1)-1),Table1[#All],1,0)

I tried this on a small sample and it all worked fine. However, when I did *exactly the same thing* in my main data I got an #N/A error.

I can't see what I'm doing wrong. The syntax worked on my sample!

Please can someone help? I can provide the sheet if you need.

Best wishes,

Chris Phillips

RE: Excel - vlookup with left & find not working

Hi Chris,

Thank you for the forum question.

You are not the first client with a similar issue. In most cases it is because the data is imported from and external data source. When the data are from external data source very often we get unwanted spaces, unprintable characters and formatting Excel cannot recognize.

Please test one of the postcodes which return #N/A.
Type the exact postcode in another cell and in another cell type =Exact(A1,A2) where A1 is cell reference with the postcode you want to test and A2 is the cell reference to the cell where you typed the Postcode. If there is an exact match the function will return TRUE if not FALSE.

If you get false change the function you use to:

=VLOOKUP(clean(trim(LEFT(E2,FIND(" ",E2,1)-1))),Table1[#All],1,0)

I hope this will solve the problem but please let me know if not.


Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

RE: Excel - vlookup with left & find not working

Thanks Jens.

Very speedy reply!

I'll give that a go and see if it works...


Best wishes,

Chris

RE: Excel - vlookup with left & find not working

Okay,

I tried that fix (manual typing postcode and doing an =EXACT(cell1, cell2)) and that reported TRUE.

I also tried typing the 1st characters into a field (eg "AB13") and doing =EXACT(cell1,relevant cell in lookup Table1) and that reported TRUE as well.

Confused...

Best wishes,

Chris

RE: Excel - vlookup with left & find not working

Hi Chris,

Is it possible to send me an example of the workbook or the workbook?

I will delete the workbook after I have had a look at it.

You can just copy some examples and paste them in a new workbook if it is confidential data.

You can send it to:

info@stl-training.co.uk

Please put my name in the subject.



Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

RE: Excel - vlookup with left & find not working

Hi Chris,

Please find the attached workbook. If You cannot find it wait a couple of minutes and press F5.

I changed your sheet 2 a little bit and the range reference in the Vlookup.



Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

Attached files...

Hosps with LETBs RCP Regional Offices (Test 04-06-15).xlsx

Excel tip:

Generating Random Numbers

To generate a random number in Excel use the = RAND() function.

The value returned will always be between 0 and 1. To convert this to some other random value, you will need to multiply the result by the highest number you want to consider. For example, if you wanted a random number between 1 and 25, you could use the following code line:
= INT(25 * RAND()+ 1)

Since RAND() will always returns a value between 0 and 1 (but never 1 itself), multiplying what it returns by 25 and then using the Integer function INT on that result will return a whole number between 0 and 24.

Finally, 1 is added to this result, so that x will be equal to a number between 1 and 25, inclusive

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.09 secs.