Solved

vb/excel formatting question

Posted on 2003-12-01
7
217 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 ]
ID: 9850940
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
ID: 9851205
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
ID: 9852839
never mind...i figured it out.
recording vba macros can be very handy!

Thanks
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 9853969
OK, never mind then :)

B)ye F)or N)ow,

f)an p)ages
0
 
LVL 29

Expert Comment

by:leonstryker
ID: 10167208
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 ]
ID: 10170481
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
ID: 10231043
PAQed, with points refunded (100)

Computer101
E-E Admin
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to debug this code 7 56
VB6 - Compare and highlight cell not the same 3 42
vb6 connector to mongodb 2 48
How to make an ADE file by code? 11 79
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

911 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

22 Experts available now in Live!

Get 1:1 Help Now