?
Solved

vb/excel formatting question

Posted on 2003-12-01
7
Medium Priority
?
221 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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…
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…
Suggested Courses

762 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