Hey everyone:
I have multiple pivot tables based on one worksheet (Master Deduction). The Master Deduction is updated once a month and then the pivot tables need to be refreshed.
This is being created for a person that is not comfortable with pivot tables and excel (a beginner). I wanted to create just a control button that when clicked will refresh all the pivot tables without the person having to go into each table to change the data range.
I thought I could do this by basing the pivot tables on a name range (called "DCFRange") that can be used by all the tables. I found a vba code that will "grow" the DCFRange with each additional monthly data and then refresh all the pivot tables. I put the control button on a different worksheet within the workbook than the pivot tables and master data sheet.
Here is the code:
Sub Update_All_Reports()
LastRow = Worksheets("Master Deductions").UsedRange.Rows.Count
LastColumn = Worksheets("Master Deductions").UsedRange.Columns.Count
ActiveWorkbook.Names.Add Name:="DCFRange", _
RefersToR1C1:="=Master Deductions!R1C1:R" & LastRow & "C" & LastColumn
ActiveWorkbook.RefreshAll
End Sub
What is happening is the DCFRange only changes for the worksheet that the control button is located on. The pivot tables doesn't change, it keeps the original range. When I'm in the worksheet of one of the Pivot Tables, I look up the Name Range and it shows the original cell ranges.
Not sure what is going or why this would happen.
thanks.
DMo
I have multiple pivot tables based on one worksheet (Master Deduction). The Master Deduction is updated once a month and then the pivot tables need to be refreshed.
This is being created for a person that is not comfortable with pivot tables and excel (a beginner). I wanted to create just a control button that when clicked will refresh all the pivot tables without the person having to go into each table to change the data range.
I thought I could do this by basing the pivot tables on a name range (called "DCFRange") that can be used by all the tables. I found a vba code that will "grow" the DCFRange with each additional monthly data and then refresh all the pivot tables. I put the control button on a different worksheet within the workbook than the pivot tables and master data sheet.
Here is the code:
Sub Update_All_Reports()
LastRow = Worksheets("Master Deductions").UsedRange.Rows.Count
LastColumn = Worksheets("Master Deductions").UsedRange.Columns.Count
ActiveWorkbook.Names.Add Name:="DCFRange", _
RefersToR1C1:="=Master Deductions!R1C1:R" & LastRow & "C" & LastColumn
ActiveWorkbook.RefreshAll
End Sub
What is happening is the DCFRange only changes for the worksheet that the control button is located on. The pivot tables doesn't change, it keeps the original range. When I'm in the worksheet of one of the Pivot Tables, I look up the Name Range and it shows the original cell ranges.
Not sure what is going or why this would happen.
thanks.
DMo