I am trying to call another macro plot within a main macro that chooses data.
I define a range quot;plotvaluesquot; in the main macro and the second macro plots
quot;plotvalues.quot; However, the variable is not being recognized. here is the
gist of what my code is like.
Sub datasplit()
....
plotvalues = ActiveSheet.Range(quot;A1:L15quot;).Address
Macroplot
End Sub()
Sub Macroplot()
Charts.Add
ActiveChart.ChartType = xlXYScatter
ActiveChart.SetSourceData Source:=Sheets(quot;Inputquot;).Range(plotvalues),
PlotBy:= _ xlColumns
End Sub()
Please help!Dim plotvalues As Range
Sub datasplit()
Set plotvalues = ActiveSheet.Range(quot;A1:L15quot;)
Macroplot
End Sub
Sub Macroplot()
Charts.Add
ActiveChart.ChartType = xlXYScatter
ActiveChart.SetSourceData Source:=plotvalues, _
PlotBy:=xlColumns
End SubOR
Dim plotvalues As String
Sub datasplit()
plotvalues = ActiveSheet.Range(quot;A1:L15quot;).Address
Macroplot
End Sub
Sub Macroplot()
Charts.Add
ActiveChart.ChartType = xlXYScatter
ActiveChart.SetSourceData Source:=Sheets(quot;Inputquot;).Range(plotvalues), _
PlotBy:=xlColumns
End Sub
HTH,
Bernie
MS Excel MVPquot;yoquot; gt; wrote in message
...
gt;I am trying to call another macro plot within a main macro that chooses data.
gt; I define a range quot;plotvaluesquot; in the main macro and the second macro plots
gt; quot;plotvalues.quot; However, the variable is not being recognized. here is the
gt; gist of what my code is like.
gt;
gt; Sub datasplit()
gt; ....
gt; plotvalues = ActiveSheet.Range(quot;A1:L15quot;).Address
gt;
gt; Macroplot
gt; End Sub()
gt;
gt; Sub Macroplot()
gt; Charts.Add
gt; ActiveChart.ChartType = xlXYScatter
gt; ActiveChart.SetSourceData Source:=Sheets(quot;Inputquot;).Range(plotvalues),
gt; PlotBy:= _ xlColumns
gt;
gt; End Sub()
gt;
gt; Please help!
gt;
Yo,
You need to pass the variable to the next Sub. Try this...
Sub datasplit()
plotvalues = ActiveSheet.Range(quot;A1:L15quot;).Address
Call Macroplot(plotvalues) 'add the variable name here in ()
End SubSub Macroplot(plotvalues) 'add the variable name here in ()
'keep the rest of your code as it is.
End SubHope that helps!
Markquot;yoquot; wrote:
gt; I am trying to call another macro plot within a main macro that chooses data.
gt; I define a range quot;plotvaluesquot; in the main macro and the second macro plots
gt; quot;plotvalues.quot; However, the variable is not being recognized. here is the
gt; gist of what my code is like.
gt;
gt; Sub datasplit()
gt; ....
gt; plotvalues = ActiveSheet.Range(quot;A1:L15quot;).Address
gt;
gt; Macroplot
gt; End Sub()
gt;
gt; Sub Macroplot()
gt; Charts.Add
gt; ActiveChart.ChartType = xlXYScatter
gt; ActiveChart.SetSourceData Source:=Sheets(quot;Inputquot;).Range(plotvalues),
gt; PlotBy:= _ xlColumns
gt;
gt; End Sub()
gt;
gt; Please help!
gt;
- Oct 18 Sat 2008 20:46
macro calling another macro variables
close
全站熱搜
留言列表
發表留言