Hi Guys,I'm getting really confused over VBA and pivot tables.My data will change week in and week out so the sizes of the spreadsheet will be different. Haven't got a clue how to do that with my current code that I have! I also don't want to end up with any "N/A columns in it!"
I haven't really got a lot of knowledge so I don't know how the above is working on that, do I need to change the range and that's it or is there more to it? Also Pivottable2? Is that because I tested one out before, do I need to change this as I won't be saving the spreadsheet and the first one won't be there tomorrow? Need a VBA course baaaadly!
Code:
Sub createpivot()
'
' createpivot Macro
' Macro recorded 23/11/2011 by jmartin
'
'
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"Sheet3!R1C1:R8471C44").CreatePivotTable TableDestination:="", TableName:= _
"PivotTable2", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
ActiveSheet.PivotTables("PivotTable2").AddFields RowFields:="Alphaname ", _
ColumnFields:="Import/Export"
ActiveSheet.PivotTables("PivotTable2").PivotFields("Over 45 Days").Orientation _
= xlDataField
Application.CommandBars("PivotTable").Visible = False
ActiveWorkbook.ShowPivotTableFieldList = False
End Sub
Last edited by a moderator: