If you can do it manually, just turn on the macro recorder before running
through the steps. When you are done with the sort, turn off the macro
recorder and view the code by hitting Alt+F11 on your keyboard.
Also, compare your recorder code to this code:
Sheets("Sheet1").Select
Range("A1").Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
Sheets("Sheet1").Range("A1").CurrentRegion).CreatePivotTable _
TableDestination:=Sheets("Sheet2").Range("A3"),
TableName:="PivotTable1", _
DefaultVersion:=xlPivotTableVersion10
Pay attention to this part:
Sheets("Sheet1").Range("A1").CurrentRegion).
You will need to replace your recorded code with that snippet of code
(change the sheet name so it matches yours). That will give you a dynamic
range; you always capture all the data for your Pivot Table. Otherwise, you
will have a fixed (or absolute range) and if you have more data than what is
in the recorded macro, you will miss what is at the bottom; quite simply your
Pivot Table will display incorrect results.
Give it a go and let me know how it works out for you!!
HTH,
Ryan---