View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mark Ivey Mark Ivey is offline
external usenet poster
 
Posts: 120
Default Graph Macro range question

See if this will work...


Sub try2()
Range("C252").Select ' The upper left most cell with data in it
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.Location Whe=xlLocationAsNewSheet, _
Name:="AHT Graph"
ActiveChart.HasLegend = False
ActiveChart.HasTitle = False
ActiveChart.Axes(xlCategory, xlPrimary).HasTitle = False
ActiveChart.Axes(xlValue, xlPrimary).HasTitle = False
ActiveChart.ChartType = xlColumnClustered
End Sub








"ElkySS" wrote in message
...
Is there a way to select a range of cells ONLY if they have data in them
while creating a graph macro. Here is the code I have as of right now:

Sub Try1()
Sheets("Raw Data").Select
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Sheets("Raw
Data").Range("C252:C256"), _
PlotBy:=xlColumns
ActiveChart.Location Whe=xlLocationAsNewSheet, Name:="AHT Graph"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
End Sub

Where is says .Range("C252:C256") works this week, but the problem starts
in
future weeks. Each week when I add data to my sheet it will add a new
number
to the end of that range (I.E. C256 next week) If I just set my range to
C252,C352 then the usable portion of my grid is smashed all the way to the
left with 90 (or so) blank (0, null, what ever you want to call it) plots
on
the line graph. This makes it unreadable. What I would like to do is
make
my range change as data is added. This macro is tied to a button in excel
so
that it can be ran only if need be and will not need to be there all of
the
time. Might sound trivial but for as many graphs as I want to make it
really
will help out with file size.