LOSING leading zeroes

tjak

Board Regular
Joined
Jan 2, 2003
Messages
117
How can I tell XL (07) to DROP leading zeroes when I import an XL file? The incoming numbers I want scrubbed contain from 4 to 10 digits and may or may not have leading zeroes in them. The leading zeroes seem 'hard wired' onto the numbers as I can't get rid of them by re-formatting the cells or multiplying by 1, etc.
Or is there some other way to get VLOOKUP to compare a .csv file to the .xls file? I see the same numbers on both files, but VLOOKUP doesn't. I've never known leading zeroes to stop VLOOKUP.
Thanx.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
The problem here is that those numbers are being imported as text, so you will have those leading zeroes and you will also have problems with vlookup (when a number is compared to a text it does not match). To make sure you have numbers stored as text you can use the formula =Type(A1). If the result is 1 you have a number, if it is 2 you have text.

To transform the numbers stored as text into actual numbers you can select the range, do a text to columns and select the output format as "number".

Hope this helps

Rafael
 
Upvote 0
It came out "text", but I don't get "number" as an output option. The sender said the file is not protected and had no suggestions on how to deal with this. The target column in the .csv file converts to numbers as per usual - it's the .xls file that won't change the data type.
Maybe here's the game-changer: I just found out that the target data in the .xls file were originally hyperlinks (no, I don't know why). They re-sent the data after removing the hyperlinks. Could this be helpful?
 
Upvote 0
Sorry, my bad. Select general as the output option of the text to columns and the numbers stored as text should be converted.
If this doesn't work I cans send you a VBA code to do it.
 
Upvote 0
First of all, try entering a cell (press F2) and hit enter to see if it changes to a number. It should work. If it does, you can use the code below:

Code:
sub test
range("A1:A100").value = range("A1:A100").value
end sub
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,299
Members
452,904
Latest member
CodeMasterX

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