Pivot table update zeros out UDF

rguy84

Board Regular
Joined
May 18, 2011
Messages
112
I have a function that I made with help from here that sums up time.
Code:
Function totalTime()
    Dim lastCell As Long
    
    'Goes to last row of the column
    lastCell = Range("M" & Rows.Count).End(xlUp).Row
    totalTime = WorksheetFunction.Sum(Range("M2:M" & lastCell))
    
    Application.Volatile
End Function
At the minute P2 says 00:45 minutes - which is correct.

On sheet 3 (stats) [i deleted sheet 2], I have a PivotTable based on sheet one. After noticing the PT doesn't auto-update, I made a button on the spreadsheet, and made the following macro:
Code:
Sub refresh_click()
    Dim pt As PivotTable
    Set pt = ActiveSheet.PivotTables("HDstats")
    pt.RefreshTable
End Sub
On click my PT updates, but my value on sheet1.P2 goes to 00:00. doing a recalculate on p2 brings back my value.

Any hints why?
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
I think the pivot table is doing something to the cells it is referencing. Since the pivot table is on it's own page, my UDF function doesn't know to update, even though it Application.Volatile. I added Application.CalculateFullRebuild to the macro above, but didn't work.
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,351
Members
452,907
Latest member
Roland Deschain

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top