Slomaro2000
Board Regular
- Joined
- Jun 4, 2008
- Messages
- 107
All,
I am in need of help with a macro to refresh a pivot tables. And also Count the Rows and Columns.
I have multiple tabs with a pivot on each. I did copy the main pivot so I was hoping to be able to refresh the main and it will refresh all of the rest?
The macro is pasting in the "DATA" tab then (trying) to count the Rows and Columns.
Then (trying) to refresh all of the "tabs" Pivots at once..
Here is what I have so. I did get it to work without counting the Columns so I will include that.
Any help would be great.
I am in need of help with a macro to refresh a pivot tables. And also Count the Rows and Columns.
I have multiple tabs with a pivot on each. I did copy the main pivot so I was hoping to be able to refresh the main and it will refresh all of the rest?
The macro is pasting in the "DATA" tab then (trying) to count the Rows and Columns.
Then (trying) to refresh all of the "tabs" Pivots at once..
Here is what I have so. I did get it to work without counting the Columns so I will include that.
'***Verifying that "You" want to continue with the Macro***
Answer = MsgBox("Are you sure you want to update?", vbQuestion + vbYesNo)
If Answer = vbNo Then Exit Sub
'***Deleting Rows***
Sheets("Data").Select
Rows("6:60000").Select
Selection.ClearContents
Range("A6").Select
'***Paste in from Business Objects***
ActiveSheet.Paste
'***Deletes the Headers that came with the Business Objects Copy***
Rows("6:9").Select
Selection.Delete Shift:=xlUp
Range("D6").Select
'***This Refreshes the charts***
'***This Counts the number of row so the charts refresh with the correct number***
' Update Pivot Table with new rows
' Set Counters = 0
rowpvt = 4
colpvt = 0
' Use counter(colpvt) to determine columns for new pivot table
Sheets("Data").Select
Range("A5").Select
10 If ActiveCell.Value = "" Then GoTo 20
rowpvt = rowpvt + 1
ActiveCell.Offset(1, 0).Select
GoTo 10
20 Sheets("Spend Trend-mo").Select
'***This updates Pivot Tables with number of rows and columns***
Sheets("Spend Trend-mo").Select
Range("B35").Select
ActiveSheet.PivotTableWizard SourceType:=xlDatabase, SourceData:="'Data'!R5C1:R" & rowpvt & colpvt
'**These will work for me if im not counting the Columns and I refresh every single tab.
' Sheets("Spend Trend-mo").Select
' Range("B35").Select
' ActiveSheet.PivotTableWizard SourceType:=xlDatabase, SourceData:="'Data'!R5C1:R" & rowpvt & "C27"
' Sheets("Spend Trend-qtr").Select
' Range("B35").Select
' ActiveSheet.PivotTableWizard SourceType:=xlDatabase, SourceData:="'Data'!R5C1:R" & rowpvt & "C27"
Any help would be great.
Last edited: