Query more than 15 digits

Jorgeoshoa8

New Member
Joined
Sep 22, 2011
Messages
2
I want to web query an online database. One of the columns contains numbers 16 digits long. When Excel imports the query I get the number in exponential format and it replaces the last number with a zero.

Example: The original is 1002002660100027, after query ends up as 1.002E+15 and reformated as text I get 1002002660100020 (Last # changed to a "0")

Is there a way to prevent the query from replacing the last number with a zero when importing from a query? Or.. can I get the query to paste as text?
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Welcome to the Board!

You can try pre-formatting that column as text.

How are you running the query though, as that might also have some options?
 
Upvote 0
Already tried pre-formatting as text and when imported it appears in exponential form, everything I do after that results in the las # replaced by zero.

Also tried query options and pasted as rich text format and html, checked preserve cell formatting and got the same results.
 
Upvote 0
The problem is that Excel is treating the the column with the 16 digits as a number and Excel is limited to 15 digits. Any digits above 15 are cut down to 0's by Excel and that's final. You can check this by simply typing in a non text formated cell 12345678901234567890. When you look at that cell again Excel has changed the number to 12345678901234500000.

Tip: If a number has 15 digits or less you can convert it from scientific notion to full notion by using the UPPER function i.e. =UPPER(A1)

So having said so there is little that can be done once Excel has gotten it's hands on a +16 digit number.

There are however several solutions:

1. When writing the query i.e. in biQuery or Access make sure that you format the 16 digit column as text and import the file using Text Import Wizard.

or

2. If you already have a csv file rename it to txt i.e. myfile.csv to myfile.txt and then import it using the Text Import Wizard formatting the column with the 16 digits to text.

or

3. Use OPEN filename FOR INPUT AS ## in VBA.

Hope this helps.
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,996
Members
452,373
Latest member
TimReeks

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