monicamarie
Board Regular
- Joined
- Sep 2, 2008
- Messages
- 72
- Office Version
- 365
I am trying to create a macro in my personal macro workbook with the following code below. The problem is that the header column listed as STATUS_TS(EDT) in the original list sometimes changes to STATUS_TS_GMT. (The file is uploaded daily from another database.) Is there a way to update the code to allow for this possibility?
Any help would be greatly appreciated!
Sub CreatePivotTable()
Dim PTCache As PivotCache
Dim PT As PivotTable
Set PTCache = ActiveWorkbook.PivotCaches.Add _
(SourceType:=xlDatabase, _
SourceData:=Range("A1").CurrentRegion.Address)
Set PT = PTCache.CreatePivotTable _
(TableDestination:="", _
TableName:="PivotTable1")
With PT
.PivotFields("STA_CD").Orientation = xlPageField
.PivotFields("ACCT_NUM").Orientation = xlRowField
.PivotFields("TRAN_AMT").Orientation = xlDataField
.PivotFields("STATUS_TS(EDT)").Orientation = xlDataField
Range("A4").Select
ActiveWindow.FreezePanes = True
End With
End Sub
Any help would be greatly appreciated!
Sub CreatePivotTable()
Dim PTCache As PivotCache
Dim PT As PivotTable
Set PTCache = ActiveWorkbook.PivotCaches.Add _
(SourceType:=xlDatabase, _
SourceData:=Range("A1").CurrentRegion.Address)
Set PT = PTCache.CreatePivotTable _
(TableDestination:="", _
TableName:="PivotTable1")
With PT
.PivotFields("STA_CD").Orientation = xlPageField
.PivotFields("ACCT_NUM").Orientation = xlRowField
.PivotFields("TRAN_AMT").Orientation = xlDataField
.PivotFields("STATUS_TS(EDT)").Orientation = xlDataField
Range("A4").Select
ActiveWindow.FreezePanes = True
End With
End Sub