A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Charts and Charting
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Change chart range with macro



 
 
Thread Tools Display Modes
  #1  
Old March 27th, 2009, 04:51 PM posted to microsoft.public.excel.charting
Greg Snidow
external usenet poster
 
Posts: 17
Default Change chart range with macro

Greetings. I am trying to name a variable that is the last row of data in a
range, then use that variable in a chart's range. I tried inserting it where
the last row would be, but it is not working, like this "A20:A & LstRow,...
Anyone have any ideas?

LstRow = [B51].End(xlUp).Row

MsgBox (LstRow)

Charts.Add
ActiveChart.ChartType = xlLine
ActiveChart.SetSourceData Source:=Sheets("Mar").Range( _
"A20:A & LstRow,C20:C46,E20:E46,G20:G46,I20:I46,K20:K46,M20 :M46"),
PlotBy:=xlColumns
ActiveChart.Location Whe=xlLocationAsObject, Name:="Mar"
ActiveChart.HasLegend = True
ActiveChart.Legend.Select
Selection.Position = xlRight
  #2  
Old March 27th, 2009, 04:57 PM posted to microsoft.public.excel.charting
Greg Snidow
external usenet poster
 
Posts: 17
Default Change chart range with macro

Ok, I got it. It should be like this RANGE("A20:A" & LstRow & ",C20:...

"Greg Snidow" wrote:

Greetings. I am trying to name a variable that is the last row of data in a
range, then use that variable in a chart's range. I tried inserting it where
the last row would be, but it is not working, like this "A20:A & LstRow,...
Anyone have any ideas?

LstRow = [B51].End(xlUp).Row

MsgBox (LstRow)

Charts.Add
ActiveChart.ChartType = xlLine
ActiveChart.SetSourceData Source:=Sheets("Mar").Range( _
"A20:A & LstRow,C20:C46,E20:E46,G20:G46,I20:I46,K20:K46,M20 :M46"),
PlotBy:=xlColumns
ActiveChart.Location Whe=xlLocationAsObject, Name:="Mar"
ActiveChart.HasLegend = True
ActiveChart.Legend.Select
Selection.Position = xlRight

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


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


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