Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

XL2000: Cannot Use Array of Data Points with Extend Method


View products that this article applies to.

This article was previously published under Q213687

↑ Back to the top


Symptoms

If you run a Visual Basic for Applications macro that attempts to use an array of data points for the Source argument of the Extend method, you receive the following error message:
Run-time error '1004':
Reference is not valid.

↑ Back to the top


Cause

In the versions of Microsoft Excel listed at the beginning of this article, the Help topic for the Extend method states that the Source argument may be either a Range object or an array of data points. This information is incorrect; the Source argument must be a Range object.

↑ Back to the top


Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

↑ Back to the top


More information

In Microsoft Excel, you can use the Extend method to add new data points to an existing series in a chart. For example, if you create a simple column chart that contains a single series, and you want to add new data points to the series, you can use a line of code similar to the following:
   ActiveChart.SeriesCollection.ExtendWorksheets("Sheet1").Range("B5:B6")
				
This line of code adds the values in cells B5:B6 in Sheet1 to the chart.

If you specify an array of data points for the Source argument of the Extend method, you receive an error message. For example, the following sample code causes the problem:
   Dim xExtras
   xExtras = Array(2, 3, 5, 7)
   ActiveChart.SeriesCollection.Extend xExtras
				
The problem occurs because xExtras refers to an array of data points, not to a Range object.

↑ Back to the top


Keywords: KB213687, kbprogramming, kbpending, kberrmsg, kbdtacode, kbbug

↑ Back to the top

Article Info
Article ID : 213687
Revision : 5
Created on : 10/11/2006
Published on : 10/11/2006
Exists online : False
Views : 230