patriciaanne
Instructor
- Feb 5, 2002
- 39
I am way over my head on this part.
Every month I am creating a pivot table and then splitting it into sheets by the report filter. So, the rows and columns on every sheet change every month. The last row of each table and sheet, says Grand Total so my macro is searching for Grand Total and then going down a row, typing the word average and then moving over to the next column.
What I need help with is - I need it to average the column but exclude the Grand Total adn then do the same thing for the next columns...etc and then do it for the other sheets.
The whole average part is not working ... the code is below.
y = Worksheets.Count - 2
For Z = 1 To y
Worksheets(Z).Select
Columns("A:A").Select
Cells.Find("Grand Total").Select
ActiveCell.Offset(1, 0).Select
ActiveCell.Value = "Average"
ActiveCell.Offset(0, 3).Select
Selection.Offset(-1, 0).Select
No = ActiveCell.Value
Selection.Offset(1, 0).Select
Avg = Average(No)
ActiveCell.Value = Avg
For x = 1 To 8
Selection.Offset(0, 1).Select
Selection.Offset(-1, 0).Select
No = ActiveCell.Value
Selection.Offset(1, 0).Select
Avg = Average(No)
ActiveCell.Value = Avg
Next x
Next Z
Any help is appreciated.. Thanks
To everything there is a season, a time for every purpose under the sun.
Every month I am creating a pivot table and then splitting it into sheets by the report filter. So, the rows and columns on every sheet change every month. The last row of each table and sheet, says Grand Total so my macro is searching for Grand Total and then going down a row, typing the word average and then moving over to the next column.
What I need help with is - I need it to average the column but exclude the Grand Total adn then do the same thing for the next columns...etc and then do it for the other sheets.
The whole average part is not working ... the code is below.
y = Worksheets.Count - 2
For Z = 1 To y
Worksheets(Z).Select
Columns("A:A").Select
Cells.Find("Grand Total").Select
ActiveCell.Offset(1, 0).Select
ActiveCell.Value = "Average"
ActiveCell.Offset(0, 3).Select
Selection.Offset(-1, 0).Select
No = ActiveCell.Value
Selection.Offset(1, 0).Select
Avg = Average(No)
ActiveCell.Value = Avg
For x = 1 To 8
Selection.Offset(0, 1).Select
Selection.Offset(-1, 0).Select
No = ActiveCell.Value
Selection.Offset(1, 0).Select
Avg = Average(No)
ActiveCell.Value = Avg
Next x
Next Z
Any help is appreciated.. Thanks
To everything there is a season, a time for every purpose under the sun.