Excel not recognising the data, while format is same

Timeless5

New Member
Joined
Sep 2, 2024
Messages
3
Office Version
  1. 2007
Platform
  1. Windows
Hi,

The data in the attached file in 2 columns are from 2 different files. When I failed to pick the data by vlookup, then I pasted samples of both for help.

Why does Excel not recognise the data, while the format of both the cells is "General"? If I try "Search", then with the data in the first row, then it doesn't find the data in 2nd row. The sheet is attached HERE.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
the first column has leading and training spaces , hence why it does not work
A1 has a leading space
A2 has a trailing space

you could use trim(A1) in column B , copy down to remove any spaces

you are showing 2007 version, i assume as its your first post - that is the version you are using
 
Upvote 0
Solution
This code removes leading/trailing space(s) from Col.A
Code:
Sub test()
    With Intersect(ActiveSheet.UsedRange, Columns(1))
        .Value = Application.Trim(.Value)
    End With
End Sub
 
Upvote 0
Thanks a lot, dear @etaf.
It's strange that if someone mistakenly adds space like this in the middle of long sheets, then Excel formulas won't work unless Cleaned.
 
Upvote 0
well, if you did want spaces, you would be equally hacked off if excel returned values regardless of leading or training spaces
you could use wildcard for the lookup - but that would be equally as bad i suspect
=vlookup( "*"&cell&"*" ,
if you wanted
123
and had in the range
1234
12356
1235
123

it would find the first one of those , so not the one with just 123 in

as i say , is it excel 2007 , later version may be possible with a formula - not sure
 
Upvote 0

Forum statistics

Threads
1,224,258
Messages
6,177,477
Members
452,782
Latest member
ZCapitao

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