Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
yo
 
Posts: n/a
Default macro calling another macro + variables

I am trying to call another macro plot within a main macro that chooses data.
I define a range "plotvalues" in the main macro and the second macro plots
"plotvalues." However, the variable is not being recognized. here is the
gist of what my code is like.

Sub datasplit()
....
plotvalues = ActiveSheet.Range("A1:L15").Address

Macroplot
End Sub()

Sub Macroplot()
Charts.Add
ActiveChart.ChartType = xlXYScatter
ActiveChart.SetSourceData Source:=Sheets("Input").Range(plotvalues),
PlotBy:= _ xlColumns

End Sub()

Please help!

  #2   Report Post  
Posted to microsoft.public.excel.misc
Bernie Deitrick
 
Posts: n/a
Default macro calling another macro + variables

Dim plotvalues As Range

Sub datasplit()
Set plotvalues = ActiveSheet.Range("A1:L15")
Macroplot
End Sub

Sub Macroplot()
Charts.Add
ActiveChart.ChartType = xlXYScatter
ActiveChart.SetSourceData Source:=plotvalues, _
PlotBy:=xlColumns

End Sub


OR

Dim plotvalues As String

Sub datasplit()
plotvalues = ActiveSheet.Range("A1:L15").Address
Macroplot
End Sub

Sub Macroplot()
Charts.Add
ActiveChart.ChartType = xlXYScatter
ActiveChart.SetSourceData Source:=Sheets("Input").Range(plotvalues), _
PlotBy:=xlColumns

End Sub



HTH,
Bernie
MS Excel MVP


"yo" wrote in message
...
I am trying to call another macro plot within a main macro that chooses data.
I define a range "plotvalues" in the main macro and the second macro plots
"plotvalues." However, the variable is not being recognized. here is the
gist of what my code is like.

Sub datasplit()
....
plotvalues = ActiveSheet.Range("A1:L15").Address

Macroplot
End Sub()

Sub Macroplot()
Charts.Add
ActiveChart.ChartType = xlXYScatter
ActiveChart.SetSourceData Source:=Sheets("Input").Range(plotvalues),
PlotBy:= _ xlColumns

End Sub()

Please help!



  #3   Report Post  
Posted to microsoft.public.excel.misc
peabrain25
 
Posts: n/a
Default macro calling another macro + variables

Yo,

You need to pass the variable to the next Sub. Try this...

Sub datasplit()

plotvalues = ActiveSheet.Range("A1:L15").Address

Call Macroplot(plotvalues) 'add the variable name here in ()
End Sub


Sub Macroplot(plotvalues) 'add the variable name here in ()

'keep the rest of your code as it is.

End Sub


Hope that helps!

Mark


"yo" wrote:

I am trying to call another macro plot within a main macro that chooses data.
I define a range "plotvalues" in the main macro and the second macro plots
"plotvalues." However, the variable is not being recognized. here is the
gist of what my code is like.

Sub datasplit()
....
plotvalues = ActiveSheet.Range("A1:L15").Address

Macroplot
End Sub()

Sub Macroplot()
Charts.Add
ActiveChart.ChartType = xlXYScatter
ActiveChart.SetSourceData Source:=Sheets("Input").Range(plotvalues),
PlotBy:= _ xlColumns

End Sub()

Please help!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro Calling Visual Basic References phauenstein Excel Discussion (Misc queries) 1 August 24th 05 09:28 PM
macro with F9 Kenny Excel Discussion (Misc queries) 1 August 3rd 05 02:41 PM
Make Alignment options under format cells available as shortcut dforrest Excel Discussion (Misc queries) 1 July 14th 05 10:58 PM
Playing a macro from another workbook Jim Excel Discussion (Misc queries) 1 February 23rd 05 10:12 PM
Macro and If Statement SATB Excel Discussion (Misc queries) 2 December 3rd 04 04:46 PM


All times are GMT +1. The time now is 09:32 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"