- Joined
- Jul 19, 2010
- Messages
- 2
- Reaction score
- 0
Hi all,
I have been struggling on that issue for the past few days, and i seriously need some help.
I have a Excel Sheet containing 13 columns of datas every 17 columns. This data is automatically filled by another macro which performs an advanced filter. Each block of data contains different number of rows (1st block will have 12, second 5, third 16...) this will change as the source file is populated. In order to treat that datas, i wrote a loop to draw a graph under each of the block of datas :
Dim x As Range
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim l As Long
'set variables
i = 0
j = 10
'Boucle
For i = 0 To 11
l = 780 * i
k = j + 3
'Set the X values
ActiveSheet.Select
Cells(1, j).Select
Set x = Range(Selection, Selection.End(xlDown))
' Select the range
Range(Cells(1, j), Cells(1, k)).Select
Range(Selection, Selection.End(xlDown)).Select
j = j + 16
'add the Chart
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SeriesCollection(1).XValues = x
ActiveChart.SeriesCollection(1).Name = "=""Serie1"""
ActiveChart.SeriesCollection(2).XValues = x
ActiveChart.SeriesCollection(2).Name = "=""Serie2"""
ActiveChart.SeriesCollection(3).XValues = x
ActiveChart.SeriesCollection(3).Name = "=""Serie3"""
ActiveChart.Location Where:=xlLocationAsObject, Name:="GraphCDS"
' ....followed by a bunch of graph formating code....
With ActiveChart.Parent
.Left = l
.Width = 634
.Top = 200
.Height = 300
End With
Next
It runs the code once, draw the graph and runtime error '1004' on the red line.
I'm working with excel 2002...i say that because on my personnal computer (window7), the code runs fine.
Thanks in advance for any help !
I have been struggling on that issue for the past few days, and i seriously need some help.
I have a Excel Sheet containing 13 columns of datas every 17 columns. This data is automatically filled by another macro which performs an advanced filter. Each block of data contains different number of rows (1st block will have 12, second 5, third 16...) this will change as the source file is populated. In order to treat that datas, i wrote a loop to draw a graph under each of the block of datas :
Dim x As Range
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim l As Long
'set variables
i = 0
j = 10
'Boucle
For i = 0 To 11
l = 780 * i
k = j + 3
'Set the X values
ActiveSheet.Select
Cells(1, j).Select
Set x = Range(Selection, Selection.End(xlDown))
' Select the range
Range(Cells(1, j), Cells(1, k)).Select
Range(Selection, Selection.End(xlDown)).Select
j = j + 16
'add the Chart
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SeriesCollection(1).XValues = x
ActiveChart.SeriesCollection(1).Name = "=""Serie1"""
ActiveChart.SeriesCollection(2).XValues = x
ActiveChart.SeriesCollection(2).Name = "=""Serie2"""
ActiveChart.SeriesCollection(3).XValues = x
ActiveChart.SeriesCollection(3).Name = "=""Serie3"""
ActiveChart.Location Where:=xlLocationAsObject, Name:="GraphCDS"
' ....followed by a bunch of graph formating code....
With ActiveChart.Parent
.Left = l
.Width = 634
.Top = 200
.Height = 300
End With
Next
It runs the code once, draw the graph and runtime error '1004' on the red line.
I'm working with excel 2002...i say that because on my personnal computer (window7), the code runs fine.
Thanks in advance for any help !