Arrays start counting at zero, unless you have "Option Base 1" at the top of the code page.
Why use a 2 dimensional array when you only have 1 dimension to store?
If that is the entire sub then run this first of all
Sub ResetScreenUpdating()
'cuz you left it turned off
Application.ScreenUpdating = True
End Sub
This is how I would write your version of the code
Sub GroupText()
Dim i As Integer
Dim a As Variant
'Application.ScreenUpdating = False 'Uncomment after testing
With Sheets("Sheet1")
With .PivotTables("PivotTable1")
With .PivotFields("ID")
ReDim a(.PivotItems.Count - 1) 'Start counting at zero
For i = 0 To UBound(a)
a(i) = .PivotItems(i + 1).Caption
Next i
End With
End With
With .PivotTables("PivotTable2").PivotFields("ID")
For i = LBound(a) To UBound(a) 'Another way of doing it.
.PivotItems(i + 1).Caption = a(i)
Next i
End With
End With
Application.ScreenUpdating = True
End Sub
And what my version would look like
Option Explicit
Sub VBAX_SamT_GroupText()
'For Help see: http://www.vbaexpress.com/forum/showthread.php?54221
Dim i As Integer
Dim PF1 As PivotField
Dim PF2 As PivotField
With Sheets("Sheet1")
Set PF1 = .PivotTables("PivotTable1").PivotFields("ID")
Set PF2 = .PivotTables("PivotTable2").PivotFields("ID")
End With
'Application.ScreenUpdating = False 'Uncomment after testing
For i = 1 To PF1.PivotItems.Count
PF2.PivotItems(i).Caption = PF1.PivotItems(i).Caption
Next i
Application.ScreenUpdating = True
End Sub
I am assuming that other than the problems mentioned, your code is good.