View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sami82[_28_] Sami82[_28_] is offline
external usenet poster
 
Posts: 1
Default Named Ranges for Chart


Hi All,

I'm trying to write a macro to produce a chart where the data change
dependant on what day is picked. So far it is only pulling up th
original day where the named range in the sheet points to. I have th
following code to run which should change the range:


Code
-------------------

ActiveAddress = ActiveCell.Offset(3, 0).Address
ActiveColumn = Left(ActiveAddress, 2)
ActiveSRange = ActiveAddress & ":" & ActiveColumn
With Worksheets("Category")
Set CVRange = .Range(ActiveSRange & .Cells(.Rows.Count, "A").End(xlUp).Row)
Set CTRange = .Range("B10:B" & .Cells(.Rows.Count, "A").End(xlUp).Row)
End With

Sheets("tmpChart").Activate
Set Cht = Charts.Add
Set Cht = Cht.Location(Whe=xlLocationAsObject, Name:="tmpChart")
With Cht
.ChartType = xlPie
.SetSourceData Source:=Sheets("Category").Range("CVRange"), _
PlotBy:=xlColumns
.SeriesCollection(1).XValues = CTRange
.HasTitle = True
.ChartTitle.Characters.Text = "Category Chart - " & ChartDay
With .Parent
.Top = Range("B7").Top
.Left = Range("B7").Left
.Name = "DayChart"
End With
End With

-------------------

Can anyone help.
Thank yo

--
Sami8
-----------------------------------------------------------------------
Sami82's Profile: http://www.excelforum.com/member.php...fo&userid=2711
View this thread: http://www.excelforum.com/showthread.php?threadid=54838