ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Number format (https://www.excelbanter.com/excel-discussion-misc-queries/74125-number-format.html)

Mark Olsen

Number format
 
Could someone tell me if this is possible and how to do it if it is in using
the custom number formats in Excel. I want to have thousands separators in
my number. I know how to add this but my problem is that if there is no
decimal part of the number then I dont want the decimal point to appear. If
there is a decimal part then I want the decimal point involved. It would be
even better if I could have it do 2 digits of precision if there is a decimal
part but that is not totally necessary.

For Example

8300
8300.25
8300.20
754

Thanks,

Mark

Toppers

Number format
 
Mark,
This cannot be done with a single format. An example using a
formula is:

Number in A1, formula in B1

=IF(MOD(A1,1)=0,TEXT(A1,"#,###"),TEXT(A1,"#,###.00 "))

You probably want the VBA equivalent which could be initiated with a
Worksheet event i.e entry in column A triggers code to set "numberformat" of
cell.

HTH

"Mark Olsen" wrote:

Could someone tell me if this is possible and how to do it if it is in using
the custom number formats in Excel. I want to have thousands separators in
my number. I know how to add this but my problem is that if there is no
decimal part of the number then I dont want the decimal point to appear. If
there is a decimal part then I want the decimal point involved. It would be
even better if I could have it do 2 digits of precision if there is a decimal
part but that is not totally necessary.

For Example

8300
8300.25
8300.20
754

Thanks,

Mark



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

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