Macros
Ideal Comma Style
VBA: Ideal Comma Style
Sub Ideal_Comma()
'This macro changes the Comma style to that preferred for the presentation of your excel workings.
dps = InputBox("How many decimal places would you like the Comma style to contain?" _
& vbNewLine & vbNewLine & "Note: Please input in '0.00' format.", "Decimal Places?")
If dps = "" Then Exit Sub
Idnt = MsgBox("Would you like force the alignment to the right of the cell?", vbYesNo, "Force Right?")
Rd = MsgBox("Would you like negative figures to appear in red text?", vbYesNo, "Red Negatives?")
If Idnt = vbYes Then
If Rd = vbYes Then
ActiveWorkbook.Styles("Comma").NumberFormat = "_-* #,##" & dps & "_);[RED]_-* (#,##" & dps & ");_-* ""-""??_);_-@_)"
Else
ActiveWorkbook.Styles("Comma").NumberFormat = "_-* #,##" & dps & "_);_-* (#,##" & dps & ");_-* ""-""??_);_-@_)"
End If
Else
If Rd = vbYes Then
ActiveWorkbook.Styles("Comma").NumberFormat = "_-#,##" & dps & "_);[RED]_-(#,##" & dps & ");_-??""-""??_);_-@_)"
Else
ActiveWorkbook.Styles("Comma").NumberFormat = "_-#,##" & dps & "_);_-(#,##" & dps & ");_-??""-""??_);_-@_)"
End If
End If
ReStyle = MsgBox("Would you like to change the numbers within this workbook to the updated comma style?", vbQuestion + vbYesNo, "ReStyle?")
If ReStyle = vbYes Then
If MidSub <> vbYes Then Call TurnStuffOff
On Error Resume Next
For Each Sheet In ActiveWorkbook.Sheets
If Sheet.Visible = False Then Sheet.Visible = True: Hide = vbYes
Sheet.Activate
For Each Cell In Cells.SpecialCells(xlCellTypeConstants, 1)
If Cell.Style <> "Percent" And Cell.NumberFormat <> "m/d/yyyy" Then Cell.Style = "Comma"
Next Cell
For Each Cell In Cells.SpecialCells(xlCellTypeFormulas, 1)
If Cell.Style <> "Percent" And Cell.NumberFormat <> "m/d/yyyy" Then Cell.Style = "Comma"
Next Cell
If Hide = vbYes Then Sheet.Visible = False
Hide = vbNo
Next Sheet
If MidSub <> vbYes Then Call TurnStuffOn
End If
End Sub