Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Stop Excel From Formating Text Starting with A Zero

This is driving me nuts!

I have a script that dumps a text file into Excel. The text file
contains some data such as the following.

Name Rev State Last First
Date
06700332 2 330 Clysdale Ron 11/20/2006 21:59

What happens though in Excel is that the 06700332 is changed to
6700332 automatically. I can't get it to stop it. I've tried
formating the column as text with no luck. Perpaps there is something
that I can programatically stick in the front of the zero to tell
Excel it's not a number. I don't know.

Can you help?
Andy
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Stop Excel From Formating Text Starting with A Zero

Perhaps there is something
that I can programmatically stick in the front of the zero to tell
Excel it's not a number.


Indeed there is, try an apostrophe '

activecell.value = "'" & "0123456"

Otherwise format the cell as Text

Regards,
Peter T

"Andy" wrote in message
...
This is driving me nuts!

I have a script that dumps a text file into Excel. The text file
contains some data such as the following.

Name Rev State Last First
Date
06700332 2 330 Clysdale Ron 11/20/2006 21:59

What happens though in Excel is that the 06700332 is changed to
6700332 automatically. I can't get it to stop it. I've tried
formating the column as text with no luck. Perpaps there is something
that I can programatically stick in the front of the zero to tell
Excel it's not a number. I don't know.

Can you help?
Andy



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Stop Excel From Formating Text Starting with A Zero

On Mar 11, 5:32*pm, "Peter T" <peter_t@discussions wrote:
Perhaps there is something
that I can programmatically stick in the front of the zero to tell
Excel it's not a number.


Indeed there is, try an apostrophe '

activecell.value = "'" & "0123456"

Otherwise format the cell as Text

Regards,
Peter T

"Andy" wrote in message

...



This is driving me nuts!


I have a script that dumps a text file into Excel. *The text file
contains some data such as the following.


Name * * * Rev * * * * * State * * * *Last * * * * *First
Date
06700332 2 330 Clysdale Ron 11/20/2006 21:59


What happens though in Excel is that the 06700332 is changed to
6700332 automatically. *I can't get it to stop it. *I've tried
formating the column as text with no luck. *Perpaps there is something
that I can programatically stick in the front of the zero to tell
Excel it's not a number. *I don't know.


Can you help?
Andy- Hide quoted text -


- Show quoted text -


Hi Peter

This works sort of. The leading zeros are there now but I also get
the single quote showing as well.

Now in Excel I have the values (for example)

'06650077
'06700219
'06700306

I would have expected the single quote to disappear. Any thoughts?

Andy
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Stop Excel From Formating Text Starting with A Zero

I had this in the past (single quote failed as well).
The solution that worked for me as follows:
Before dumping the data, define the format of the entire column (e.g.
E:E) as text - manually or with VBA.
Then dump your data.
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Stop Excel From Formating Text Starting with A Zero

I think this is probably what you are looking for. I have an add-in
that uses very large numbers preceded with a 0. So, not only does
excel convert them into scientific notation, but it removes the zero.

With .Range("E:E")
.NumberFormat = "0"
.Value = .Value
End With

I had to use .Value = .Value because this particular format change
doesn't always apply until the cells are re-evaluated.


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Stop Excel From Formating Text Starting with A Zero

What's your numberformat

Regards,
Peter T

"Andy" wrote in message
...
On Mar 11, 5:32 pm, "Peter T" <peter_t@discussions wrote:
Perhaps there is something
that I can programmatically stick in the front of the zero to tell
Excel it's not a number.


Indeed there is, try an apostrophe '

activecell.value = "'" & "0123456"

Otherwise format the cell as Text

Regards,
Peter T

"Andy" wrote in message

...



This is driving me nuts!


I have a script that dumps a text file into Excel. The text file
contains some data such as the following.


Name Rev State Last First
Date
06700332 2 330 Clysdale Ron 11/20/2006 21:59


What happens though in Excel is that the 06700332 is changed to
6700332 automatically. I can't get it to stop it. I've tried
formating the column as text with no luck. Perpaps there is something
that I can programatically stick in the front of the zero to tell
Excel it's not a number. I don't know.


Can you help?
Andy- Hide quoted text -


- Show quoted text -


Hi Peter

This works sort of. The leading zeros are there now but I also get
the single quote showing as well.

Now in Excel I have the values (for example)

'06650077
'06700219
'06700306

I would have expected the single quote to disappear. Any thoughts?

Andy


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I stop text from disappearing when I wrap text in Excel? Shavonne Excel Worksheet Functions 0 March 22nd 10 12:38 PM
How can I stop Excel from formating my infromation as a Date? Eric Excel Discussion (Misc queries) 2 December 4th 09 06:56 PM
Stop Outlook from starting when typing email addresses into a cell asg2307 Excel Discussion (Misc queries) 2 January 16th 07 07:23 AM
loop question trying to bring excel into autocad text not starting in correct place [email protected] Excel Programming 0 February 10th 06 12:59 PM
Stop autoloading a New worksheet when starting Excel Jwhite Setting up and Configuration of Excel 2 June 21st 05 03:45 PM


All times are GMT +1. The time now is 08:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"