My code is clumsy because I am searching, testing....
I'd like to use a two-dimensional array filled with data from several spreadsheets and give it as a data source for a chart. I cannot achieve this in any way.
ReDim Preserve always gives me an error, no matter how I use the function. I need several thousand rows and only two columns.
In general, I want to achieve what is in the link:
using an array is probably the easiest solution.
I'd like to use a two-dimensional array filled with data from several spreadsheets and give it as a data source for a chart. I cannot achieve this in any way.
ReDim Preserve always gives me an error, no matter how I use the function. I need several thousand rows and only two columns.
In general, I want to achieve what is in the link:
VBA filling the chart with data from multiple sheets
Another problem with VBA and charts.... I need to populate a chart with data from multiple worksheets, only where the InRange value is True. I don't want several different overlapping data, the result should be summed, as if in one sequence. So for example 5 sheets each with 1000 cells, there...
www.mrexcel.com
Code:
Dim arr() As Variant, cell As Range, i%
Dim objChrt As ChartObject
Dim chrt As Chart
Dim StartVal_X As String, EndVal_X As String, SheetName As String
Dim StartVal_Y As String, EndVal_Y As String
With Sheets("Graph_Template")
.Activate
'Scatter graph of weight ratios
Set objChrt = .ChartObjects("Chart 3")
objChrt.Activate
Set chrt = objChrt.Chart
i = 0
ReDim arr(20000, 2)
For Each cell In Sheets("Family Pack 01.11").Range("D2" & ":" & "D3699")
i = i + 1
'ReDim Preserve arr(UBound(arr, 1) + 1, 1 To 2)
arr(i, 1) = cell.Value
'Debug.Print cell.Value
Next
'Debug.Print arr()
Dim rData As Range
rData.Value = WorksheetFunction.Transpose(arr)
chrt.SeriesCollection(1).Value = rData
chrt.Refresh
End With
Debug.Print "Weekly"