Formating style macro help

woody3737

Board Regular
Joined
Sep 19, 2008
Messages
82
I have these 4 very simple style formatting macros, but I can't quite get them to work right every time. The issue is the information between the quotation marks. Here is the code:

Sub Number()
'
' Number Macro
' Number format with no decimals
'
'
Selection.NumberFormat = "#,###"
End Sub


Sub Dollar()
'
' Dollar Macro
' Currency format with no decimals
'
'
Selection.NumberFormat = "$#,###"
End Sub


Sub Price()
'
' Price Macro
' Currency with 2 decimals
'
'
Selection.NumberFormat = "$#,###.#0"
End Sub


Sub Percentage()
'
' Percentage Macro
' Percentage with 1 decimal place
'
'
Selection.NumberFormat = "#,###.#%"
End Sub


In the first one, I want it to show a number with a comma and no decimal places, but when the number is less than 0.5, due to rounding, it returns a blank cell instead of a 0.

In the second one, I want it to show a currency with the symbol and no decimals, but I run into the same problem as above.

In the third one, I want it to show a retail price with 2 decimals, but when it is less than 1, which it usually is, it comes back looking like "$.45" when I would like it to display "$0.45" to make it easier to discern.

In the fourth one, I want a percentage with 1 decimal, but sometimes get something like "57.%" for some reason I can't figure out.

Thanks in advance. I appreciate and welcome any suggestions.
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Forum statistics

Threads
1,216,767
Messages
6,132,599
Members
449,738
Latest member
brianm3y3r

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top