Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do you insert rows in a sheet that has a PivotTable
Your code is not inserting an entire row, it inserts one cell at the top of
column A. The Pivot Table would then be one row off from the rest of the table in column A. So it does not allow you to do this. ActiveSheet.Rows(1).Insert will insert a new row at row 1, pushing the entire sheet down 1 row and keeping the table aligned. Mike F "Gail Hurn" wrote in message ... 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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
2007 excel work sheet will not allow to insert rows or columns | Excel Discussion (Misc queries) | |||
copy rows based on conditions and insert them into another sheet... | Excel Programming | |||
copy cells in two columns if in bold to another sheet and insert rows | Excel Programming | |||
Insert Rows in Balance Sheet Template | New Users to Excel | |||
In Excell sheet i want to insert more than 65,536 rows how i can . | Excel Worksheet Functions |