I have written a module that gives me the run time error 1004. I am not sure which one of my variables is incorrect.
Thanks for any help provided Tom
The error is highlighted in Blue
The worksheet Has two tabs on it.
Tab1 is called Summary
Tab2 is called Data
The Worksheet Name is AHS_Cnts
The columns that have data in them are A - E on tab DATA
Currently the last row is 2931
Thanks for any help provided Tom
The error is highlighted in Blue
The worksheet Has two tabs on it.
Tab1 is called Summary
Tab2 is called Data
The Worksheet Name is AHS_Cnts
The columns that have data in them are A - E on tab DATA
Currently the last row is 2931
Code:
Public Function xlPivotRefresh(sSheetName As String)
Dim iBotRow As Integer
Dim sDataArea As String
Dim pvt As PivotTable
' For Each pvt In ActiveSheet.PivotTables
' MsgBox pvt.Name & ":" & pvt.TableRange1
'
'Count Last Row of DATA Sheet
Call xlCalcBotRow(iBotRow)
sDataArea = "DATA!$A$1" & ":" & "$E$" & iBotRow
'sSheetName = "DATA"
With goXl.ActiveWorkbook
.Worksheets(sSheetName).Activate
End With
'Rename Pivot Table Data with new range
'C5 means column 5 of the pivot table
ActiveWorkbook.Names.Add Name:="PivotData", RefersToR1C1:="=DATA!R1C1:R" & iBotRow & "C5"
With goXl.ActiveSheet
.PivotTables("PivotTable1").RefreshTable
End With
'Rename wizard range
With goXl.ActiveSheet
[Blue] .PivotTableWizard SourceType:=xlDatabase, SourceData:="DATA!R1C1:R" & iBotRow & "C5", TableDestination:="Summary", TableName:="PivotTable1" [\Blue]
.PivotTables("PivotTable1").PivotCache.Refresh
End With
'Next
'Remove Pivottable Field List
ActiveWorkbook.ShowPivotTableFieldList = False
End Function
[\code]