XL5: Cannot Set Chart Data Marker Color Using Macro

Last reviewed: September 12, 1996
Article ID: Q112176
The information in this article applies to:
  • Microsoft Excel for Windows, version 5.0

SYMPTOMS

In Microsoft Excel, when the background or foreground color of a chart data marker is set to none, you cannot change the color of that data marker with a macro.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem was corrected in Microsoft Excel for Windows version 5.0c.

WORKAROUND

To set the color of a chart data marker using a macro, when the color of the chart marker is set to none, use the ClearFormats method in a Visual Basic procedure, or the Clear function in a Microsoft Excel version 4.0 macro as in the following examples:

Visual Basic Examples

   ' Set Series 1 data marker background color to red
   Charts(1).SeriesCollection(1).ClearFormats
   Charts(1).SeriesCollection(1).MarkerBackgroundColorIndex = 3

   ' Set Series 1 data markers foreground color to red
   Charts(1).SeriesCollection(1).ClearFormats
   Charts(1).SeriesCollection(1).MarkerForegroundColorIndex = 3

Microsoft Excel version 4.0 Examples

The following example clears the Series 1 data marker formatting on the active chart, and sets the background color to red:

   =SELECT("S1")
   =CLEAR(2)
   =PATTERNS(,,,,0,,,3,,)

The following example clears the Series 1 data marker formatting on the active chart, and sets the foreground color to red:

   =SELECT("S1")
   =CLEAR(2)
   =PATTERNS(,,,,0,,3,,,)

Note that when you use the above examples, the drawback of using the ClearFormats method and the Clear function is that all the formatting for the selected data markers is reset. Because of this resetting, you must set all formatting for the selected data markers after using either command.

Microsoft provides examples of Visual Basic procedures for illustration only, without warranty either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. This Visual Basic procedure is provided 'as is' and Microsoft does not guarantee that it can be used in all situations. Microsoft does not support modifications of this procedure to suit customer requirements for a particular purpose. Note that a line that is preceded by an apostrophe introduces a comment in the code--comments are provided to explain what the code is doing at a particular point in the procedure. Note also that an underscore character (_) indicates that code continues from one line to the next. You can type lines that contain this character as one logical line or you can divide the lines of code and include the line continuation character. For more information about Visual Basic for Applications programming style, see the "Programming Style in This Manual" section in the "Document Conventions" section of the "Visual Basic User's Guide."

Microsoft provides macro examples for illustration only, without warranty either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. This macro is provided as is and Microsoft in no way guaranties that the following code can be used in all situations and will not support modifications of the code to suit specific customer requirements.

REFERENCES

For more information about Formatting Data Markers, choose the Search button in Help and type:

   chart data markers


KBCategory: kbprb
KBSubcategory:

Additional reference words: 5.00



THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 12, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.