have the following code which is supposed to list the items in a particularly Pivot Field from a Pivot Table in a different workbook. I have two questions; firstly is this code concise enough as it seems to take quite a long time for what it has to? Secondly, when I am running the code and I press escape it completes the macro in a very quick time and was wondering if I could code in a key press to simulate the escape key?
The code is
Edit : Forgot to mention that the PivotField list is only 200 items long and the code takes over a minute to complete and about 10 seconds when I press escape.
Any help would be much appreciated.
Regards,
Jonathan
The code is
Code:
Sub Pivotfields()
With Workbooks("Pivot Data").Sheets("Pivot Tables").PivotTables("PivotTable15")
Sheet9.Range("A4").Select
l = .PivotFields("Contract Number").PivotItems.Count
k = 2
Do
ActiveCell.Value = .PivotFields("Contract Number").PivotItems(k).Name
ActiveCell.Offset(1, 0).Activate
k = k + 1
Loop While k <> l
End With
End Sub
Any help would be much appreciated.
Regards,
Jonathan