Hi all,
I have a code that another member kindly put together for me. It works on my desktop (Excel 2010) but when I log on via Citrix and open Excel 2003. When I refresh the pivot table the dates change to US format so instead of 07/12/2016, 08/12/2016 & 09/12/2016 it changes to 12/07/2016, 12/08/2016 & 12/09/2016.
Sub AllWorksheetPivots()
Const SUMMARY_PIVOT_DATASHEET As String = "Summary_pivot_data"
Const PIVOT_SHEETS As String = "Camerons|Tadcaster|Hereford|Royal|Caledonian|Zoutewoude"
Dim ws As Worksheet
Dim cell As Range
Dim pvt As PivotTable
Dim pcell As PivotCell
Dim pi As PivotItem
Dim sheetList() As String
Dim sheetName
Dim x As Long, y As Long, rowNum As Long
sheetList = Split(PIVOT_SHEETS, "|")
' either get or create sheet for summary data for the pivot table
On Error Resume Next
Set ws = ThisWorkbook.Sheets(SUMMARY_PIVOT_DATASHEET)
On Error GoTo 0
If ws Is Nothing Then
Set ws = ThisWorkbook.Sheets.Add(after:=ThisWorkbook.Sheets("Summary"))
ws.Name = SUMMARY_PIVOT_DATASHEET
End If
ws.UsedRange.Clear
ws.Range("A1:F1").Value2 = Array("Plan", "Location", "Week", "Date", "Vol", "Count")
rowNum = 2
For Each sheetName In sheetList
For Each pvt In ThisWorkbook.Sheets(sheetName).PivotTables
' check for rows of actual data - every pivot has grand totals so will always have 1 row
If pvt.DataBodyRange.Rows.Count > 1 Then
For Each cell In pvt.DataBodyRange.Columns(1).Cells
Set pcell = cell.PivotCell
If pcell.RowItems.Count > 1 Then
For x = 1 To pcell.RowItems.Count
ws.Cells(rowNum, x + 2) = pcell.RowItems(x).Value
Next x
ws.Cells(rowNum, 1).Value2 = sheetName
ws.Cells(rowNum, 2).Value2 = pcell.ColumnItems(1).Value
ws.Cells(rowNum, 6).Value2 = cell.Value2
rowNum = rowNum + 1
End If
Next cell
End If
Next pvt
Next sheetName
ws.Range("A1").CurrentRegion.Name = SUMMARY_PIVOT_DATASHEET
Sheets("Summary").PivotTables("Summary_pivot").RefreshTable
End Sub
Is there was way to work around this?
Thanks in advance
Bookmarks