Hi there,

Is there a known issue creating pivot tables with macros giving different results than when creating pivot tables manually?

I recorded a macro for creating a pivot table (edited it a little in some parts) to automate a process and each time I run it, the data/results in the pivot table that it gives me are different then if I create the pivot table manually (w/o the macro). I'm not doing anything different in the macro (aside from a prompt to open the file that I want and to save it at the end).

I have no idea why this is happening but it's quite annoying. I even included checks to make sure that all the data is included (in case some rows were missed) and I can't figure out the issue.

Here is the bulk of it. I have no idea why it's behaving so weird and would certainly entertain any thoughts on how to correct this issue.

Thank you in advance
-----------
Sub standings()
'
importFILE = Application.GetOpenFilename("Text,*.*")
Workbooks.OpenText Filename:=importFILE, DataType:=xlDelimited, Comma:=True
' dump out if Cancel is Hit
If importFILE = "False" Then Exit Sub
Rows("1:11").Select
Selection.Delete Shift:=xlUp
' Count number of rows with data to use for SourceData in pivot table
sLastRow = Sheets(1).Rows.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Address
numRows = Mid(sLastRow, InStrRev(sLastRow, "$") + 1)
' Test the count and display on screen
' MsgBox numRows
' To apply this to your statement you could use:
Dim sourceDataRange As String
sourceDataRange = "R1C1:R" & numRows & "C34"
' Show me the RANGE!!
MsgBox ActiveSheet.Name
MsgBox sourceDataRange
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"" & ActiveSheet.Name & "!R1C1:R" & numRows & "C34").CreatePivotTable TableDestination:="", TableName _
:="PivotTable1", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
With ActiveSheet.PivotTables("PivotTable1").PivotFields( _
"current_owner_salesrep")
.Orientation = xlRowField
.Position = 1
End With
Sheets("Sheet1").Name = "PivotTable"
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("extended_netprice"), "Sum of extended_netprice", _
xlSum
ActiveWorkbook.ShowPivotTableFieldList = False
Application.CommandBars("PivotTable").Visible = False