Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Graph macro question

I Have a multiple graphs inside a worksheet. But need to have a macro that
will allow me to sleect a range inside the worksheet for each graph. How can
I assign with a macro the range for each graph?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Graph macro question

Edwin,

The following line of code would set the source data for Chart 1 on the
active sheet to A2:B5

ActiveSheet.ChartObjects("Chart 1").Chart.SetSourceData
Source:=Sheets("Sheet1").Range("A2:B5")

Is that what you wanted?

If the chart is a separate sheet the code would be:

Charts("Chart1").SetSourceData Source:=Sheets("Sheet1").Range("A2:B5")

hth,

Doug


"Edwin Merced" wrote in message
...
I Have a multiple graphs inside a worksheet. But need to have a macro that
will allow me to sleect a range inside the worksheet for each graph. How

can
I assign with a macro the range for each graph?




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Graph macro question

Lets say I have 1 graph but need a macro that will make a selection and
graph (exactly like the first graph) but with another range. Whats the macro
or code for that. How can I instruct with a macro which range to select in
order for it to graph?

"Doug Glancy" wrote in message
...
Edwin,

The following line of code would set the source data for Chart 1 on the
active sheet to A2:B5

ActiveSheet.ChartObjects("Chart 1").Chart.SetSourceData
Source:=Sheets("Sheet1").Range("A2:B5")

Is that what you wanted?

If the chart is a separate sheet the code would be:

Charts("Chart1").SetSourceData Source:=Sheets("Sheet1").Range("A2:B5")

hth,

Doug


"Edwin Merced" wrote in message
...
I Have a multiple graphs inside a worksheet. But need to have a macro

that
will allow me to sleect a range inside the worksheet for each graph. How

can
I assign with a macro the range for each graph?






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Graph macro question

Edwin,

I'm still not sure exactly what you want, and not sure I'd be able to answer
even if I was.

Have you tried turning on the macro recorder and then creating the graph
that you want? That could be a good way to start to answer your question.

hth,

Doug

"Edwin Merced" wrote in message
...
Lets say I have 1 graph but need a macro that will make a selection and
graph (exactly like the first graph) but with another range. Whats the

macro
or code for that. How can I instruct with a macro which range to select in
order for it to graph?

"Doug Glancy" wrote in message
...
Edwin,

The following line of code would set the source data for Chart 1 on the
active sheet to A2:B5

ActiveSheet.ChartObjects("Chart 1").Chart.SetSourceData
Source:=Sheets("Sheet1").Range("A2:B5")

Is that what you wanted?

If the chart is a separate sheet the code would be:

Charts("Chart1").SetSourceData Source:=Sheets("Sheet1").Range("A2:B5")

hth,

Doug


"Edwin Merced" wrote in message
...
I Have a multiple graphs inside a worksheet. But need to have a macro

that
will allow me to sleect a range inside the worksheet for each graph.

How
can
I assign with a macro the range for each graph?








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 90
Default Graph macro question

Edwin -

Can you just copy the chart (I like to hold down Ctrl while dragging the
original), then right click on the new one, select Source Data from the
pop up menu, and select the Data Range with the mouse?

Of course you can always write a macro:

Sub CopyChartWithNewRange()
Dim rng As Range
ActiveSheet.Shapes(ActiveChart.Parent.Name).Duplic ate.Select
On Error Resume Next
Set rng = Application.InputBox( _
Prompt:="Select a data range for the new chart.", Type:=8)
If Err.Number = 0 Then
ActiveChart.SetSourceData Source:=rng
End If
End Sub

- Jon
-------
Jon Peltier, Microsoft Excel MVP
http://www.geocities.com/jonpeltier/Excel/index.html
_______

Edwin Merced wrote:

Lets say I have 1 graph but need a macro that will make a selection and
graph (exactly like the first graph) but with another range. Whats the macro
or code for that. How can I instruct with a macro which range to select in
order for it to graph?

"Doug Glancy" wrote in message
...

Edwin,

The following line of code would set the source data for Chart 1 on the
active sheet to A2:B5

ActiveSheet.ChartObjects("Chart 1").Chart.SetSourceData
Source:=Sheets("Sheet1").Range("A2:B5")

Is that what you wanted?

If the chart is a separate sheet the code would be:

Charts("Chart1").SetSourceData Source:=Sheets("Sheet1").Range("A2:B5")

hth,

Doug


"Edwin Merced" wrote in message
...

I Have a multiple graphs inside a worksheet. But need to have a macro


that

will allow me to sleect a range inside the worksheet for each graph. How


can

I assign with a macro the range for each graph?







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
Graph Question kyoshirou Excel Discussion (Misc queries) 1 September 26th 06 04:18 AM
Graph Question nikki Excel Discussion (Misc queries) 1 March 10th 06 06:46 PM
Graph Question nikki Excel Discussion (Misc queries) 1 March 9th 06 01:17 AM
Bar Graph Question kmatch Excel Discussion (Misc queries) 2 September 20th 05 09:06 PM
bar graph question anantathaker Excel Discussion (Misc queries) 1 June 17th 05 03:44 PM


All times are GMT +1. The time now is 10:17 AM.

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"