LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Bill Martin
 
Posts: n/a
Default Format a Cell from VBA

I've got a macro that does a bunch of things and at the end puts a number value
in a cell. I would like to write out that value to be displayed in a fixed
format with one decimal digit. Somehow it *almost* works for me. I've tried to
use a statement like:

ActiveCell.Offset(0,0) = FORMAT(X,"0.0")

When X is some kind of long decimal like 1.33333 it works nicely and shows "1.3"
in the cell as expected. When X is an even integer like 1.0 though, it only
shows "1" in the cell. Yet from the spreadsheet I can click to set the number
of digits afterwards and it works as expected.

In addition to the format "0.0" I've tried "#.#" with the same result. I also
tried "#.#_" and it does force the correct format, but of course appends the
character on the end which I don't want.

What's the necessary incantation here? I've been unable to find anything useful
in the Help system or in Walkenbach's book -- doubtlessly I haven't been able to
guess the proper search term for the answer I want.

Thanks...

Bill
 
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
Reference Cell in custom format???? lil_ern63 Excel Discussion (Misc queries) 3 September 1st 05 02:27 PM
Why does my format keep changing in the cell? Denise Excel Discussion (Misc queries) 0 August 30th 05 04:23 PM
how do I format a cell reference to move as source changes KGray Excel Worksheet Functions 1 August 13th 05 12:41 AM
Show Blank is cell value=0 but count as a zero in sum. How to format this cell ? Markus Obermayer Excel Worksheet Functions 1 January 4th 05 08:01 PM
How do I unhide the cell format function in Excel 2000 Len Melcer Excel Worksheet Functions 2 December 15th 04 06:49 PM


All times are GMT +1. The time now is 01:25 AM.

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"