#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Number Format in VBA

How to a force VBA to show an integer as a fixed number of digits? eg
display 240 as 0000240

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default Number Format in VBA

Set the format (FormatCellsCustom) to 0000000

--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"PhilM" wrote in message
oups.com...
How to a force VBA to show an integer as a fixed number of digits? eg
display 240 as 0000240



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 196
Default Number Format in VBA

Hi Phil

Assuming you want your variable myVar to hold this value:

myVar = Format(240,"0000000")

Note that this is held as a string value. If you simply want to
display 240 in your sheet in the desired format, then you need to set
the number format of the cell that holds the value:

Range("A1").Value = 240
Range("A1").NumberFormat = "0000000"

Hope this helps!

Richard

PhilM wrote:

How to a force VBA to show an integer as a fixed number of digits? eg
display 240 as 0000240


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
Number format in cells Jim Excel Worksheet Functions 3 June 7th 06 04:57 PM
Convert [h]:mm sum total format to number format Guy Excel Worksheet Functions 1 August 5th 05 05:56 AM
Number format for Combobox MBlake Excel Discussion (Misc queries) 1 June 29th 05 03:25 AM
16 digit number wont keep alteration unless format cell to text Croc001 Excel Discussion (Misc queries) 3 March 30th 05 09:12 AM
How do i change numbers in text format to number format? Greg New Users to Excel 1 December 14th 04 05:22 PM


All times are GMT +1. The time now is 05:43 AM.

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

About Us

"It's about Microsoft Excel"