C
Carl
I know there have been previous posts on this but I am relatively new
to VBA and am having trouble adapting it to my needs.
I currently have a workbook that is charting a trend of data verses
time. Every month we dump in more data and refresh the pivot tables
that sort it out. The charts are all on one sheet and the pivot
tables are spread out throughout different sheets. I am currently
trying to make a macro that will automatically adjust the source data
to include new data every month by using the COUNTA function to set
the amount of rows included in the chart. I would also like it to
only use a max of 48 months (48 rows) but I cant work that out later.
Right now I have the followingprimarily from boards I've read-
explanations/efforts in caps)
Sub Macro1()
Dim rng As Range
Set rng = Range("C6:C27").Offset(Range("DO2").Value, 0) (' I HAVE A
COUNTA FUNTION HERE THAT TELLS HOW MANY ROWS ARE USED)
Sheets("Sheet3").Select '(THIS IS WHERE SOURCE DATA IS)
sRange = "='" & ActiveSheet.Name & "'!" & rng.Address(1, 1, xlR6C3)
(THIS PART STUMPS ME BUT DATA STARTS ON ROW6 AND COLUMN 3)
Sheets("Charts").Select
ActiveSheet.ChartObjects("Chart 2").Chart.SeriesCollection(1).Values =
sRange (THIS IS WHERE I GET RUN TIME ERROR "UNABLE TO SET VALUES
PROPERTY OF SERIES CLASS)
END SUB
to VBA and am having trouble adapting it to my needs.
I currently have a workbook that is charting a trend of data verses
time. Every month we dump in more data and refresh the pivot tables
that sort it out. The charts are all on one sheet and the pivot
tables are spread out throughout different sheets. I am currently
trying to make a macro that will automatically adjust the source data
to include new data every month by using the COUNTA function to set
the amount of rows included in the chart. I would also like it to
only use a max of 48 months (48 rows) but I cant work that out later.
Right now I have the followingprimarily from boards I've read-
explanations/efforts in caps)
Sub Macro1()
Dim rng As Range
Set rng = Range("C6:C27").Offset(Range("DO2").Value, 0) (' I HAVE A
COUNTA FUNTION HERE THAT TELLS HOW MANY ROWS ARE USED)
Sheets("Sheet3").Select '(THIS IS WHERE SOURCE DATA IS)
sRange = "='" & ActiveSheet.Name & "'!" & rng.Address(1, 1, xlR6C3)
(THIS PART STUMPS ME BUT DATA STARTS ON ROW6 AND COLUMN 3)
Sheets("Charts").Select
ActiveSheet.ChartObjects("Chart 2").Chart.SeriesCollection(1).Values =
sRange (THIS IS WHERE I GET RUN TIME ERROR "UNABLE TO SET VALUES
PROPERTY OF SERIES CLASS)
END SUB