Dim WSD As Worksheet, WSD2 As Worksheet
Dim PTCache As PivotCache
Dim PT As PivotTable, PTbl As PivotTable
Dim PRange As Range
Dim LastRow As Long
Set WSD = Worksheets("Main Data")
Set WSD2 = Worksheets("Pivot Detail")
vFields = Range("Table_PivotData").Value
'define input area and set up a Pivot Cache
LastRow = WSD.Cells(65536, 1).End(xlUp).Row
WSD.Activate
WSD.Cells(1, 1).Resize(LastRow, 37).Select
ActiveWorkbook.Names.Add Name:="PData", RefersTo:=Selection
Set PRange = WSD.Cells(1, 1).Resize(LastRow, 37)
Set PTCache = ActiveWorkbook.PivotCaches.Add(xlDatabase, Range("PData"))
Set PT = PTCache.CreatePivotTable(WSD2.Range("A10"), "Detail Pivot")
PT.ManualUpdate = True
WSD2.Activate
'...continue to play with the pivot table