Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 153
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   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 153
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

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
Use a combo to change the data range for a chart? WildlyHarry Excel Discussion (Misc queries) 1 March 27th 09 02:17 PM
A copy of a chart doesn't change when the original has new range Piotr (Peter)[_2_] Charts and Charting in Excel 10 September 8th 08 06:55 PM
trying to programmatically change chart data range with vb.net doofy[_2_] Charts and Charting in Excel 7 February 8th 08 02:02 PM
How to dynamically change the series range of a chart ? ptek Charts and Charting in Excel 2 October 5th 06 04:42 AM
Macro to change Chart Range when inserting a column Mark Charts and Charting in Excel 1 September 13th 05 01:12 PM


All times are GMT +1. The time now is 10:08 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"