How can I format the numbers in a column of various worksheets in excel that I am writing to with a vb6 app?
When opening the worksheet the numbers are being changed sometimes.
Eg. The numbers are inventory numbers. 12.345 stays the same but 02.456 changes to 2.456 and 32. 120 changes to 32.12. I would appreciate any and all help with this problem.
Thanks newbie rick

RE: Formatting numbers in a column in excel through a vb6 application by anonymous

anonymous
Fri Apr 30 03:11:05 CDT 2004

Try prefixing them with a single quote (') if you want to force Excel to apply text formatting. This will leave the characters exactly as they are, it won't try any number formatting. But you may not be able to sum them up as numbers, but that's ok if they're ID numbers.

Re: Formatting numbers in a column in excel through a vb6 application by Jan

Jan
Fri Apr 30 03:17:58 CDT 2004

"newbie rick" <anonymous@discussions.microsoft.com>'s wild
thoughts were released on Thu, 29 Apr 2004 11:41:03 -0700
bearing the following fruit:

>How can I format the numbers in a column of various worksheets in excel that I am writing to with a vb6 app?
>When opening the worksheet the numbers are being changed sometimes.
>Eg. The numbers are inventory numbers. 12.345 stays the same but 02.456 changes to 2.456 and 32. 120 changes to 32.12. I would appreciate any and all help with this problem.
>Thanks newbie rick

If you want the code to do it, then record a macro.

You can format an entire column.

I've found formatting in excel to be ropey at best,
particually with dates. Excel 'helpfully' tries to apply
formatting for you.




--
Jan Hyde (MVP - Visual Basic)

Occult: A young horse. (Keith Nance)

[Abolish the TV Licence - http://www.tvlicensing.biz/]


Re: Formatting numbers in a column in excel through a vb6 application by anonymous

anonymous
Fri Apr 30 08:56:02 CDT 2004

usin
wbkData.Sheets(MySheet).Cells(y, x).NumberFormat = "#,##0;(#,##0)

normally works. There's no point in using anything but 'custom' numberformat (i.e. where you specify your own string) unless it's just a mock-up.

Re: Formatting numbers in a column in excel through a vb6 application by Jeff

Jeff
Fri Apr 30 10:33:54 CDT 2004


"newbie rick" <anonymous@discussions.microsoft.com> wrote in message
news:18261A9A-E768-456C-AC67-9B8581AC9BF9@microsoft.com...

> How can I format the numbers in a column of various worksheets in excel
that
> I am writing to with a vb6 app?
> When opening the worksheet the numbers are being changed sometimes.
> Eg. The numbers are inventory numbers. 12.345 stays the same but 02.456
> changes to 2.456 and 32. 120 changes to 32.12. I would appreciate any and
> all help with this problem.

You don't want Excel to treat them as numbers; you want it to treat them as
text. Set the NumberFormat of the column to "@".