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:
SYMPTOMSIn 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.
CAUSEThis 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.
STATUSMicrosoft 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 INFORMATIONThe 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.
REFERENCESFor more information about the NumberFormat Property, choose the Search button in MS Excel Visual Basic Help and type:
NumberFormat Property |
|
KBCategory: kbprg
©1997 Microsoft Corporation. All rights reserved. Legal Notices. |