Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Creating Charts in VBA.
Written by Allen Wyatt (last updated October 25, 2025)
This tip applies to Excel 97, 2000, 2002, and 2003
Excel is very handy at creating charts from data in a worksheet. What if you want to create a chart directly from VBA, without using any data in a worksheet? You can do this by "fooling" Excel into thinking it is working with information from a worksheet, and then providing your own. The following macro illustrates this concept:
Sub MakeChart()
'Add a new chart
Charts.Add
'Set the dummy data range for the chart
ActiveChart.SetSourceData Sheets("Sheet1").Range("a1:d4"), _
PlotBy:=xlColumns
'Manually set the values for the data series
ActiveChart.SeriesCollection(1).Formula = _
"=SERIES(""First Data"",{""a"",""b"",""c"",""d""},{2,3,4,5},1)"
ActiveChart.SeriesCollection(2).Formula = _
"=SERIES(""Second Data"",{""a"",""b"",""c"",""d""},{6,7,8,9},2)"
ActiveChart.SeriesCollection(3).Formula = _
"=SERIES(""Third Data"",{""a"",""b"",""c"",""d""},{10,11,12,13},3)"
End Sub
The comments in this example explain what is going on for each step. When setting the dummy data range, the SetSourceData method assumes the range is on a worksheet named Sheet1. If you don't have such a sheet in your workbook, you need to alter the command accordingly.
Later, when manually setting the values for the data series, the SERIES command is used to specify the label for the series (First Data, Second Data, and Third Data), the array of category labels (a, b, c, and d in all series), the array of values for the series, and a number specifying which series number this represents.
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2622) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Creating Charts in VBA.
Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!
If you create a user form in VBA that includes checkboxes, you may want to make the checkboxes larger. You can't adjust ...
Discover MoreWant to add a bunch of blank rows to a your data and have those rows interspersed among your existing rows? Here's a ...
Discover MoreIf someone sends you a worksheet that has lots of data in it, you might want to "spread out" the data so you can have ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2025-11-06 02:02:02
sandeepkothari
Wonderful!
Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2025 Sharon Parq Associates, Inc.
Comments