Chart Problem

G

Guest

Guest
I created a chart in my workbook, it has
noly one series. Then I made a simple sub
procedure to change the data
in the series by feeding an array to
SeriesCollection(1).Values. And I got run-
time error 1004, depending on the array size
and the data format. For example, using
array size 10 and data like 1.11111111,
everything is fine; but if I use array size
100 and data like 1.11, I got run-time error.
The following is the sub procedure. I am
using EXCEL 2000 in Windows 2000.

Sub test()
Dim cht As Chart
Dim Xdata() As String
Dim data() As Double

Dim average As Double
Dim i As Integer
Dim k As Integer
Dim r As Range

k = 100
average = 1.11

ReDim data(0 To k) As Double
ReDim Xdata(0 To k) As String

Set cht = ThisWorkbook.Charts("Chart1")

For i = 0 To k
Xdata(i) = "Point" & CStr(i + 1)
data(i) = average

Next i

With cht
'.SeriesCollection(1).XValues = Xdata
.SeriesCollection(1).Values = data

End With

End Sub
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Forum statistics

Threads
1,214,518
Messages
6,119,988
Members
448,935
Latest member
ijat

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top