Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format Excel Cell

Status
Not open for further replies.

demopro

Programmer
Apr 23, 2001
117
US
Hello,

I am sending data from a web page to Excel (opening Excel in the browser) and have been stuck with one small issue. When I pass in a variable of "0000000" Excel sees this as a number and truncates it to a single zero. I need this to remain the same as I passed it in as.

The field in the database is a char where the “0000000” comes from.
 

Hi,
Code:
MyValue = 0
[A1] = Format(MyValue,"0000000")


Skip,

[glasses] [red]A palindrome gone wrong?[/red]
A man, a plan, a ROOT canal...
PULLEMALL![tongue]
 
And what happens if you pass in a variable of [tt]"'[/tt]0000000" ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
SkipVought,

Do I add this code to my .asp page?
 
Scratch that last comment. I guess what I am looking for is a way to do this from the .asp page. Somewhat like the formatnumber function that I am using for dollar fields.
 
OK, if anyone else needs the quick fix for this here it is. I check the variable to see if it = "00000000" then assign it as "O00000000" where the first "0" is the letter O and not a zero. This way it will look similar to a zero and stop Excel from truncating the eight zeros to a single zero.

I know this is not the best way to do this but it is all that I can think of.

Thanks for the help,
Jim
 
Sorry, just did and it thru off the formating of the cells and returned this '00000000
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top