ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Formatting a cell (https://www.excelbanter.com/excel-programming/278464-formatting-cell.html)

Jean Claude

Formatting a cell
 
Hi all

Using VB, I created a new sheet.
I would like to format a certain column so when my VB program put numerical
values starting with zero, the zero would stay.
Example: "01234" should read "01234" when the file is opened with Excel.
At the moment when I open the file with Excel, the reading is "1234" (the
leading zero is omitted)

Maybe I should format the column as "Text"
How do I do that please?

TIA
Guy




Phil Pugliese

Formatting a cell
 
One way is to do the following:


[Object.]Cells(2,1).value = "'" & 01234.

If you need to use the value for some other calculation do
this:


X = Val([Object.]Cells(2,1).value ) * 24

Val([Object.]Range("B15").value ) = Val([Object.]Cells
(2,1).value ) * 24

note: If the cell you are getting data from is on
the "activesheet" you do not need the [Object.].



-----Original Message-----
Hi all

Using VB, I created a new sheet.
I would like to format a certain column so when my VB

program put numerical
values starting with zero, the zero would stay.
Example: "01234" should read "01234" when the file is

opened with Excel.
At the moment when I open the file with Excel, the

reading is "1234" (the
leading zero is omitted)

Maybe I should format the column as "Text"
How do I do that please?

TIA
Guy



.



All times are GMT +1. The time now is 11:46 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com