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

I frequently make simple date & total graphs using rolling 52 week sales
totals for different product lines. The dates are always in the top row
(D1:BC1). The totals are always the last row of those same columns (D though
BC). Unfortunately the last row can change depending upon the number of
products in that line. The recorded macro below works when the totals are on
the 6th row. I've been trying to modify this with some sort of €ślastrow"
function to dynamically change the "D6:BC6" to the appropriate row, but so
far haven't been able to get anything I've tried to work. Please help.

Range("D1:BC1,D6:BC6").Select
Range("BC6").Activate
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Sheets("week").Range("D1:BC1,D6:BC6")
ActiveChart.Location Whe=xlLocationAsObject, Name:="week"
ActiveChart.Axes(xlCategory).Select
With ActiveChart.Axes(xlCategory)
.MinimumScaleIsAuto = True
.MaximumScaleIsAuto = True
.BaseUnitIsAuto = True
.MajorUnitIsAuto = True
.MinorUnitIsAuto = True
.Crosses = xlAutomatic
.AxisBetweenCategories = True
.ReversePlotOrder = True
End With
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Dynamic Charting

Try this at the start of to select the range

Dim r1, r2, myrange As Range

lrow = Range("D1").End(xlDown).Row
Set r1 = Range(Cells(1, 4), Cells(1, 55))
Set r2 = Range(Cells(lrow, 4), Cells(lrow, 55))
Set myrange = Union(r1, r2)
myrange.Select
Cells(lrow, 55).Activate

The xlDown only works if there are no blank rows until the end.

Then use this for your data source line

ActiveChart.SetSourceData Source:=myrange

stone-man wrote:
I frequently make simple date & total graphs using rolling 52 week sales
totals for different product lines. The dates are always in the top row
(D1:BC1). The totals are always the last row of those same columns (D though
BC). Unfortunately the last row can change depending upon the number of
products in that line. The recorded macro below works when the totals are on
the 6th row. I've been trying to modify this with some sort of "lastrow"
function to dynamically change the "D6:BC6" to the appropriate row, but so
far haven't been able to get anything I've tried to work. Please help.

Range("D1:BC1,D6:BC6").Select
Range("BC6").Activate
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Sheets("week").Range("D1:BC1,D6:BC6")
ActiveChart.Location Whe=xlLocationAsObject, Name:="week"
ActiveChart.Axes(xlCategory).Select
With ActiveChart.Axes(xlCategory)
.MinimumScaleIsAuto = True
.MaximumScaleIsAuto = True
.BaseUnitIsAuto = True
.MajorUnitIsAuto = True
.MinorUnitIsAuto = True
.Crosses = xlAutomatic
.AxisBetweenCategories = True
.ReversePlotOrder = True
End With


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Dynamic Charting

Thanks. That's just what I needed !

" wrote:

Try this at the start of to select the range

Dim r1, r2, myrange As Range

lrow = Range("D1").End(xlDown).Row
Set r1 = Range(Cells(1, 4), Cells(1, 55))
Set r2 = Range(Cells(lrow, 4), Cells(lrow, 55))
Set myrange = Union(r1, r2)
myrange.Select
Cells(lrow, 55).Activate

The xlDown only works if there are no blank rows until the end.

Then use this for your data source line

ActiveChart.SetSourceData Source:=myrange

stone-man wrote:
I frequently make simple date & total graphs using rolling 52 week sales
totals for different product lines. The dates are always in the top row
(D1:BC1). The totals are always the last row of those same columns (D though
BC). Unfortunately the last row can change depending upon the number of
products in that line. The recorded macro below works when the totals are on
the 6th row. I've been trying to modify this with some sort of "lastrow"
function to dynamically change the "D6:BC6" to the appropriate row, but so
far haven't been able to get anything I've tried to work. Please help.

Range("D1:BC1,D6:BC6").Select
Range("BC6").Activate
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Sheets("week").Range("D1:BC1,D6:BC6")
ActiveChart.Location Whe=xlLocationAsObject, Name:="week"
ActiveChart.Axes(xlCategory).Select
With ActiveChart.Axes(xlCategory)
.MinimumScaleIsAuto = True
.MaximumScaleIsAuto = True
.BaseUnitIsAuto = True
.MajorUnitIsAuto = True
.MinorUnitIsAuto = True
.Crosses = xlAutomatic
.AxisBetweenCategories = True
.ReversePlotOrder = True
End With



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
Dynamic charting [email protected] Charts and Charting in Excel 1 December 3rd 07 08:05 PM
dynamic charting [email protected] Charts and Charting in Excel 3 November 11th 07 02:16 PM
Dynamic charting widman Charts and Charting in Excel 2 October 26th 06 11:00 PM
Dynamic Charting Richard Flame Charts and Charting in Excel 3 July 3rd 06 06:39 PM
Dynamic Charting sergv Excel Discussion (Misc queries) 2 September 2nd 05 04:43 PM


All times are GMT +1. The time now is 01:36 AM.

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

About Us

"It's about Microsoft Excel"