ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to programmatically access Number Format String in the Format (https://www.excelbanter.com/excel-programming/409429-how-programmatically-access-number-format-string-format.html)

xiao

How to programmatically access Number Format String in the Format
 
Hi,
We know that Excel allows us to format a cell in the €śFormat Cells Dialog€ť.
Then in the program, we can get the format string using
((Range)ActiveSheet.Cells[1, 1]).NumberFormat.
My question is:
Is there a way to programmatically access all the Number Format String in
the Format Cells Dialog without selecting each format manually?
Thanks,



JLGWhiz

How to programmatically access Number Format String in the Format
 
If you mean pull up some kind of menu, the answer is no. The dialogs method
is the only way to do that. However, you can use NumberFormat to set the
format to whatever format is available in the dialog box by simply specifying
the format name for certain ones such as "General", "Accounting", etc. Or you
can set cutom formats such as $##,##0; ( $##,##0) to get even dollars
displayed. NumberFormat is one of the more versatile of the VBA facilities.

"xiao" wrote:

Hi,
We know that Excel allows us to format a cell in the €śFormat Cells Dialog€ť.
Then in the program, we can get the format string using
((Range)ActiveSheet.Cells[1, 1]).NumberFormat.
My question is:
Is there a way to programmatically access all the Number Format String in
the Format Cells Dialog without selecting each format manually?
Thanks,



xiao

How to programmatically access Number Format String in the For
 
JLGWhiz,
Thanks a lot for your reply.
My question is:
can we list all the available NumberFormat in the Format Cells Dialog? In
other words, can we use a foreach() loop to display all the default
NumberFormat supported by Excel without openning the Format Cells Dialog? If
yes, could you show me some code to do so?
Thx.


"JLGWhiz" wrote:

If you mean pull up some kind of menu, the answer is no. The dialogs method
is the only way to do that. However, you can use NumberFormat to set the
format to whatever format is available in the dialog box by simply specifying
the format name for certain ones such as "General", "Accounting", etc. Or you
can set cutom formats such as $##,##0; ( $##,##0) to get even dollars
displayed. NumberFormat is one of the more versatile of the VBA facilities.

"xiao" wrote:

Hi,
We know that Excel allows us to format a cell in the €śFormat Cells Dialog€ť.
Then in the program, we can get the format string using
((Range)ActiveSheet.Cells[1, 1]).NumberFormat.
My question is:
Is there a way to programmatically access all the Number Format String in
the Format Cells Dialog without selecting each format manually?
Thanks,



JLGWhiz

How to programmatically access Number Format String in the For
 
No, you cannot access the NumberFormat options using a loop. The Dialogs box
is the only way that I know of to display and select options. Otherwise, you
have to explicitly assign the NumberFormat as a specific type.

"xiao" wrote:

JLGWhiz,
Thanks a lot for your reply.
My question is:
can we list all the available NumberFormat in the Format Cells Dialog? In
other words, can we use a foreach() loop to display all the default
NumberFormat supported by Excel without openning the Format Cells Dialog? If
yes, could you show me some code to do so?
Thx.


"JLGWhiz" wrote:

If you mean pull up some kind of menu, the answer is no. The dialogs method
is the only way to do that. However, you can use NumberFormat to set the
format to whatever format is available in the dialog box by simply specifying
the format name for certain ones such as "General", "Accounting", etc. Or you
can set cutom formats such as $##,##0; ( $##,##0) to get even dollars
displayed. NumberFormat is one of the more versatile of the VBA facilities.

"xiao" wrote:

Hi,
We know that Excel allows us to format a cell in the €śFormat Cells Dialog€ť.
Then in the program, we can get the format string using
((Range)ActiveSheet.Cells[1, 1]).NumberFormat.
My question is:
Is there a way to programmatically access all the Number Format String in
the Format Cells Dialog without selecting each format manually?
Thanks,




All times are GMT +1. The time now is 12:29 PM.

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