Microsoft KB Archive/120360

= Microsoft Knowledge Base =

Incorrect NumberFormat Argument in Recorded Visual Basic Macro
Last reviewed: September 12, 1996

Article ID: Q120360

The information in this article applies to:


 * Microsoft Excel for the Macintosh, version 5.0

SYMPTOMS
In Microsoft Excel, when you turn on the macro recorder, using the Visual Basic language, and you format a cell using a currency number format, the NumberFormat argument is recorded incorrectly.

CAUSE
This behavior only occurs when you apply a number format that contains parentheses, such as the following currency format code:

$#,##0_);($#,##0) The following line is recorded when you apply the format code above in a Visual Basic macro:

Selection.NumberFormat = "$#,##0;-$#,##0" The parentheses are not included in the recorded format code. Note that when you run the recorded macro, the correct format code is applied to the selected cell, even though the argument appears incorrect in the recorded macro.

STATUS
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION
The MS Excel Visual Basic Help gives the following example for the NumberFormat property:

Columns("C").NumberFormat = "$#,##0.00_);[Red]($#,##0.00)" This syntax works correctly, even though this is not the syntax that is recorded when you apply this format while the macro recorder is running.