View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Abel MacAdam Abel MacAdam is offline
external usenet poster
 
Posts: 10
Default Excel 2007: Graph macro using reletive reference?

Hi Joel,

Thanks for helping me. Sadly, no. The graph is wiped clean. The range it
uses for its data is altered to a location containing no data. Even a 'Undo'
did not get me my data back.

Abel

"Joel" wrote:

Something like this


Sub Past_month_click()
LastRow = 15
Set MyRange = Range("B1:B" & LastRow)
'
ActiveSheet.ChartObjects("Graph 15").Activate
ActiveChart.SetSourceData Source:=MyRange
End Sub


"Abel MacAdam" wrote:

Hi,

I recorded the following macro:
Sub Past_month_click()
'
ActiveSheet.ChartObjects("Graph 15").Activate
ActiveSheet.ChartObjects("Graph 15").Activate
ActiveChart.SetSourceData Source:=Range("B50:H54")
End Sub

What do I want to accomplish? I have a range of data per month. When I do my
thing in the sheet I want to add the last month to my graph. In Excel I have
to right click the graph, change the data range, press the right key,
followed by pressing the Enter key. This I would like to do by the macro. So,
the Range("B50:H54") must become a relative reference. What do I need to
change in the above code to accomplish that?

Abel