Charting help

S

saziz

I have set up a macro to generate a simple chart. I want to know ho
can I (through code) restrict the plot range only upto the last dat
cells, instead of me giving a range in macro. Appreicate ur help
Thank you
Sazi
 
D

duane

If your data has no zeroes you want to exclude this would work.
Otherwise have macro create a range like this of only non zero data.


Range("A1").CurrentRegion.Name = "chartdata"
Range("chartdata").Sort Key1:=Range("B1"), _
Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Charts.Add
ActiveChart.ChartType = xlColumnClustered
With ActiveChart
.SetSourceData Source:=Sheets("chartdata").Range("chartdata"), _
PlotBy:=xlColumns
.HasTitle = True
.ChartTitle.Characters.Text = "whateveryouwant"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text
"whateveryouwant"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text
"whateveryouwant"
End Wit
 
S

saziz

saziz said:
*I have set up a macro to generate a simple chart. I want to kno
how can I (through code) restrict the plot range only upto the las
data cells, instead of me giving a range in macro. Appreicate u
help
Thank you
Saziz *

Duane Thank you for your help. I had to take sorting line out since
have massaged the data before plotting.
BTW what could be the code to delete empty cells out from a set range
would appreciate if you can help me.
Thanks
Sazi
 
Top