How do you insert rows in a sheet that has a PivotTable
I am trying to programatically add rows to a worksheet that has a PivotTable,
but I always get an error.
Here is the code:
Dim sheet As Excel.Worksheet
Dim cell, newCell As Excel.Range
Set sheet = Application.ActiveSheet
Set cell = sheet.Cells(1, 1)
cell.Select
cell.Insert (Excel.XlInsertShiftDirection.xlShiftDown)
This code works if the worksheet does not contain a PivotTable. The
PivotTable is located at cell A3 so it shouldn't be in the way of the
inserted row.
Thanks in advance for any insight on how to make this work.
|