Worksheet Calculate
I had no trouble at all using VBA to assign this format to a cell:
Sub FormatPctNonZero()
Selection.NumberFormat = "#,##0.00%;-#,##0.00%;;@"
End Sub
Alternatively, if you have a Style (i.e. "PctNonZero [1]") defined that
applies this format, then the VBA code would look like the following:
Sub FormatPctNonZeroStyle()
Selection.Style = "PctNonZero [1]"
End Sub
Just be aware that to use this method, the Style must exist in the
workbook, otherwise you will get the following run-time error (at least in
Excel 2000):
"Run-time error '450':
"Wrong number of arguments or invalid property assignment."
--
Regards,
Bill Renaud
|