Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

vb/excel formatting question

Posted on 2003-12-01
7
Medium Priority
?
222 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Technology Partners: 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!

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Suggested Courses

604 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