I have some data which is the source for a pivot table I am building with following VBA script.
The code is creating a new sheet and generating pivot table there but I want the pivot table to be present in the same sheet where source data is.
It also requires to check till where existing data is and have to select an empty cell.
Sub ApplyPivot()
ActiveWorkbook.Sheets("NOIDA").Select
Range("A1").Select
Set objTable = Sheet1.PivotTableWizard
Set objField = objTable.PivotFields("sector")
objField.Orientation = xlRowField
Set objField = objTable.PivotFields("number")
objField.Orientation = xlColumnField
Set objField = objTable.PivotFields("quantity")
objField.Orientation = xlDataField
objField.Function = xlCount
objField.NumberFormat = " ######"
End Sub