Solved

vb/excel formatting question

Posted on 2003-12-01
7
216 Views
Last Modified: 2010-05-01
Hi,

I have a 16 digit number in a tab delimited text file. When I import it into excel, it does one of the following:

1) converts the last digit into a zero if i do the following formatting:
xlsheet.columns(2).NumberFormat = "#"

2) converts the number into scientific notation if i do the following formatting:
xlsheet.columns(2).NumberFormat = "@"

I thought the second should treat it as text!

Does anyone know what sort of formatting is needed in order to leave the number as is. I dont know if this makes a difference, but I am importing the tab limited file using the following code:

dim CSVBook as workbook
dim xlBook as workbook

Set CSVBook = Workbooks.Open(filename)
CSVBook.Sheets(1).Copy xlBook.Worksheets(1)
CSVBook.Close

xlbook.saveas FileName:=newFileName, FileFormat:=xlExcel9795

Any help would be appreciated.

Thanks,
AJ

0
Comment
Question by:aj_2003
7 Comments
 
LVL 35

Expert Comment

by:[ fanpages ]
Comment Utility
Hi AJ,

Regardless of the number of digits displayed or formatted, MS-Excel stores numbers with up to 15 digits of precision.

If a number contains more than 15 significant digits, Excel converts the extra digits to zeros (0).

Could you change your file to enclose the digits in quotation marks prior to import,
e.g.
"1234567890123456"<tab>etc.
?

BFN,

fp.
0
 

Author Comment

by:aj_2003
Comment Utility
Hi fp,

I tried putting quotes around the 16 digit number - excel removes the quotes and still makes the last digit a zero. Any other ideas of how to import the number as text?

Also, are there any invisible characters that I can place before or after the number? I tried putting a space before/after but excel simply removed it. When I place a single quote, it works but they are visible when viewing the excel file.

By the way, what's BFN (Be a Fan?)?

Thanks
AJ
0
 

Author Comment

by:aj_2003
Comment Utility
never mind...i figured it out.
recording vba macros can be very handy!

Thanks
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 35

Expert Comment

by:[ fanpages ]
Comment Utility
OK, never mind then :)

B)ye F)or N)ow,

f)an p)ages
0
 
LVL 29

Expert Comment

by:leonstryker
Comment Utility
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

PAQ/Refund
 
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

leonstryker
EE Cleanup Volunteer
0
 
LVL 35

Expert Comment

by:[ fanpages ]
Comment Utility
Agreed.

The asker fixed his/her own problem.

If possible, could he/she post the solution that addressed the original question for future readers?

Thanks.

BFN,

fp.
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
Comment Utility
PAQed, with points refunded (100)

Computer101
E-E Admin
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now