excel vlookup left

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

Excel - vlookup with left & find not working | Excel forum

resolvedResolved · Medium Priority · Version 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:

Use the Ctrl-key for quick navigation in Excel 2010

If you want to move quickly to the right, left, top or bottom of your spreadsheet, just press Ctrl and one of the arrow keys. If you want to then select all the data in that particular row or column, hold down the Shift key and press Ctrl and an arrow key.

View all Excel hints and tips


Server loaded in 0.08 secs.