C
crichardson
I am writing some vba procedures to create charts. Most of it i
working but when I try to generalise the procedure and use variables t
specify sheetname and range name, it falls over.
I have got the following to work at least with a variable sheetname bu
it's messy and the range names are literal.
private Procedrue createChart(sheetname)
dataSheetName
With ActiveChart
...
.SetSourceData Source:=Sheets(SheetName).Range _
(SheetName & "!range1, " & dataSheetName & _
"!range2, " & dataSheetName & _
"!range3"), PlotBy:=xlColumns
...
End with
...
end sub
What I would like is to is have my proc handle variable source dat
sheet names and variable range names.
private procedure createchart(sheetname, rangevar1, rangevar2
rangevar3)
and call the above procedure like this...
call createchart("sheet1", "range1", "range2", "range3")
Note that I have already got to the point where the appropriate range
have been created in the vba code. Those ranges are the source dat
for the charts that I wish to create through the code. In reality,
won't pass the range names as parameters to the createchart procedur
as I can derive their names from the sheetname. However, for the sak
of simplicity, I'm illustrating the issue using parameters.
Any suggestions?
Cliv
working but when I try to generalise the procedure and use variables t
specify sheetname and range name, it falls over.
I have got the following to work at least with a variable sheetname bu
it's messy and the range names are literal.
private Procedrue createChart(sheetname)
dataSheetName
With ActiveChart
...
.SetSourceData Source:=Sheets(SheetName).Range _
(SheetName & "!range1, " & dataSheetName & _
"!range2, " & dataSheetName & _
"!range3"), PlotBy:=xlColumns
...
End with
...
end sub
What I would like is to is have my proc handle variable source dat
sheet names and variable range names.
private procedure createchart(sheetname, rangevar1, rangevar2
rangevar3)
and call the above procedure like this...
call createchart("sheet1", "range1", "range2", "range3")
Note that I have already got to the point where the appropriate range
have been created in the vba code. Those ranges are the source dat
for the charts that I wish to create through the code. In reality,
won't pass the range names as parameters to the createchart procedur
as I can derive their names from the sheetname. However, for the sak
of simplicity, I'm illustrating the issue using parameters.
Any suggestions?
Cliv