S
Sami82
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(Where:=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
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(Where:=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