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.
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.