Hi guys, I am new to VBA. Like very very new and plan on enrolling in a class within a month. Until then, I have been working on this but it keeps informing me of Compile error: Named argument not found.
this is my code
Public Sub Set_Up_All()
Dim pvttbl As PivotTable
Dim wsdata As Worksheet
Dim mgdata As Range
Dim pvttblcache As PivotCache
Dim wspvttbl As Worksheet
Dim pvtfld As PivotField
Set wsdata = Worksheets("Sheet1")
Set wsdata = Worksheets("Sheet2")
Set mgdata = wsdata.Range("A:J")
Sheets.Add
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, _
SourceData:=mgdata, Version:=x1PivotTableVersion12).createpivotable pivottablerange:=wspvttbl.Range("A1"), tablename:="PivotTable1"
Set pvttble = wspvttbl.PivotTables("PivotTable1")
Set pvtfld = pvttbl.PivotFields("User ID")
pvtfld.Orientation = xlRowField
pvtfld.Position = 1
Set pvtfld = pvttbl.PivotFields("Transaction ID")
pvtfld.Orientation = xlRowField
pvtfld.Position = 2
Set pvtfld = pvttbl.PivotFields("Difference in Mins")
pvtfld.Orientation = xlRowField
pvtfld.Position = 3
Worksheets("Sheet2").PivotTables("PivotTable1").PivotFields("User ID").Subtotals = Array _
(False, False, False, False, False, False, False, False, False, False, False, False)
Worksheets("Sheets2").PivotTables("PivotTable1").PivotFields("Transaction ID").Subtotals _
= Array(False, False, False, False, False, False, False, False, False, False, False, False)
Worksheets("Sheets2").PivotTables("PivotTable1").PivotFields("Difference in Mins"). _
Subtotals = Array(False, False, False, False, False, False, False, False, False, False, _
False, False)
Columns("B:B").EntireColumn.AutoFit
Worksheets("Sheet2").PivotTables("PivotTable1").PivotSelect "'Difference in Mins'[All]" _
, xlLabelOnly, True
Range("K13").Select
Worksheets("Sheets2").PivotTables("PivotTable1").PivotFields("Difference in Mins"). _
PivotFilters.Add2 Type:=xlCaptionIsBetween, Value1:="0.00", Value2:= _
"3.00"
pvttble.ManualUpdate = True
End Sub
can someone please help me? is there something wrong at the 'Version:=x1PivotTableVersion12' part?
im trying to build a pivot that will created for the data im using. i have to pull over 50000 lines of data every day and this would save me some time to not having to create it. I would really appreciate any and all help, please and thank you! this i got from a combination of trying to record it, realizing too late that pivot table recorded macros wont work in Excel 2007, and using online resources.
Thanks, Jaxs
this is my code
Public Sub Set_Up_All()
Dim pvttbl As PivotTable
Dim wsdata As Worksheet
Dim mgdata As Range
Dim pvttblcache As PivotCache
Dim wspvttbl As Worksheet
Dim pvtfld As PivotField
Set wsdata = Worksheets("Sheet1")
Set wsdata = Worksheets("Sheet2")
Set mgdata = wsdata.Range("A:J")
Sheets.Add
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, _
SourceData:=mgdata, Version:=x1PivotTableVersion12).createpivotable pivottablerange:=wspvttbl.Range("A1"), tablename:="PivotTable1"
Set pvttble = wspvttbl.PivotTables("PivotTable1")
Set pvtfld = pvttbl.PivotFields("User ID")
pvtfld.Orientation = xlRowField
pvtfld.Position = 1
Set pvtfld = pvttbl.PivotFields("Transaction ID")
pvtfld.Orientation = xlRowField
pvtfld.Position = 2
Set pvtfld = pvttbl.PivotFields("Difference in Mins")
pvtfld.Orientation = xlRowField
pvtfld.Position = 3
Worksheets("Sheet2").PivotTables("PivotTable1").PivotFields("User ID").Subtotals = Array _
(False, False, False, False, False, False, False, False, False, False, False, False)
Worksheets("Sheets2").PivotTables("PivotTable1").PivotFields("Transaction ID").Subtotals _
= Array(False, False, False, False, False, False, False, False, False, False, False, False)
Worksheets("Sheets2").PivotTables("PivotTable1").PivotFields("Difference in Mins"). _
Subtotals = Array(False, False, False, False, False, False, False, False, False, False, _
False, False)
Columns("B:B").EntireColumn.AutoFit
Worksheets("Sheet2").PivotTables("PivotTable1").PivotSelect "'Difference in Mins'[All]" _
, xlLabelOnly, True
Range("K13").Select
Worksheets("Sheets2").PivotTables("PivotTable1").PivotFields("Difference in Mins"). _
PivotFilters.Add2 Type:=xlCaptionIsBetween, Value1:="0.00", Value2:= _
"3.00"
pvttble.ManualUpdate = True
End Sub
can someone please help me? is there something wrong at the 'Version:=x1PivotTableVersion12' part?
im trying to build a pivot that will created for the data im using. i have to pull over 50000 lines of data every day and this would save me some time to not having to create it. I would really appreciate any and all help, please and thank you! this i got from a combination of trying to record it, realizing too late that pivot table recorded macros wont work in Excel 2007, and using online resources.
Thanks, Jaxs