Solved

vb/excel formatting question

Posted on 2003-12-01
7
219 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA/SQL - Connect to SQL server and pull data 4 137
Run code from text file in vb 1 87
Visual Studio 2005 text editor 10 49
Formula problem with Excel attachment 6 43
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…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
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…

696 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