Hi there
I'm sure that this is an easy fix but I'm having difficulty figuring it out. I have recorded a macro that created a pivot table. The macro works great. However, I have a few questions in the macro below. Right now, the range is fixed. Is there a way to make the range not fixed in my macro, in case I need to add more rows. I don't want to make my worksheet that the Pivot Table takes the data from into a table.
I also have 5 fields. I want to be able to sort by each field but my pivot table won't allow me to do that. It only allows me to sort by my first field. Is there a way for me to sort by each of the 5 fields? Most of the fields have dollar amounts in them except for the first field. Thanks
Sub PivotTable()
Sheets("Sheet3").Select
Cells.Select
ActiveWindow.SmallScroll Down:=-9
Selection.Clear
Range("A1").Select
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Sheet2!R1C1:R373C29", Version:=6).CreatePivotTable TableDestination:= _
"Sheet3!R3C1", TableName:="PivotTable3", DefaultVersion:=6
Sheets("Sheet3").Select
Cells(3, 1).Select
End Sub
I'm sure that this is an easy fix but I'm having difficulty figuring it out. I have recorded a macro that created a pivot table. The macro works great. However, I have a few questions in the macro below. Right now, the range is fixed. Is there a way to make the range not fixed in my macro, in case I need to add more rows. I don't want to make my worksheet that the Pivot Table takes the data from into a table.
I also have 5 fields. I want to be able to sort by each field but my pivot table won't allow me to do that. It only allows me to sort by my first field. Is there a way for me to sort by each of the 5 fields? Most of the fields have dollar amounts in them except for the first field. Thanks
Sub PivotTable()
Sheets("Sheet3").Select
Cells.Select
ActiveWindow.SmallScroll Down:=-9
Selection.Clear
Range("A1").Select
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Sheet2!R1C1:R373C29", Version:=6).CreatePivotTable TableDestination:= _
"Sheet3!R3C1", TableName:="PivotTable3", DefaultVersion:=6
Sheets("Sheet3").Select
Cells(3, 1).Select
End Sub