Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
2007 excel work sheet will not allow to insert rows or columns David Excel Discussion (Misc queries) 1 January 24th 09 07:30 PM
copy rows based on conditions and insert them into another sheet... [email protected] Excel Programming 3 November 25th 07 10:22 PM
copy cells in two columns if in bold to another sheet and insert rows [email protected][_2_] Excel Programming 4 June 12th 07 06:01 PM
Insert Rows in Balance Sheet Template Teacher_Becky New Users to Excel 2 November 21st 05 02:15 AM
In Excell sheet i want to insert more than 65,536 rows how i can . Girish.G Excel Worksheet Functions 3 April 6th 05 12:51 PM


All times are GMT +1. The time now is 08:43 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"