LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 146
Default Coded to delete extra rows after pivot table

I tried to use some code given to me on this site to delete rows after
macro-generated pivot tables, but this did not work. I received an error
message, "Method 'Range' of Object '_Worksheet' failed". The code that I
received was as follows:
Dim myR As Range
ActiveSheet.PivotTables("PivotTable1").PivotSelect "", xlDataAndLabel, True
Set myR = Selection

Range(myR(myR.Cells.Count)(2), Cells(Rows.Count, 1)).EntireRow.Delete
Range(myR(myR.Cells.Count)(1, 2), Cells(1, Columns.Count)).EntireColumn.Delete
'
'
'
This code sandwiched in with other code as shown below:
Sheets("PIV_SOF").Visible = True
Application.Goto "SOF_BACK_TO_SUMMARY"
Worksheets("PIV_SOF").Copy _
After:=Worksheets(Worksheets.Count)
Sheets("PIV_SOF").Visible = False

Set Sh = ActiveSheet
Sh.Name = Target & "-Source of Funds"
Sh.Tab.ColorIndex = 33
For Each pt In Sh.PivotTables
With pt
With .PivotFields("RC")
For Each pi In .PivotItems
If LCase(pi.Value) = LCase(Target.Value) Then
..CurrentPage = pi.Value

Dim myR As Range
ActiveSheet.PivotTables("PivotTable1").PivotSelect "", xlDataAndLabel,
True
Set myR = Selection

Range(myR(myR.Cells.Count)(2), Cells(Rows.Count, 1)).EntireRow.Delete
Range(myR(myR.Cells.Count)(1, 2), Cells(1,
Columns.Count)).EntireColumn.Delete

Call Formatting_SOF
'
'
'
'
Any suggestions?
Thanks in advance.



--
Kent Lysell
IBM Consultant
Ottawa, Ontario
 
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
Cannot delete extra rows jmj713 Excel Discussion (Misc queries) 6 January 8th 09 09:23 PM
How do I change my data or add extra rows in a Pivot Table for Ex. Kathryn Excel Discussion (Misc queries) 0 June 16th 08 01:22 AM
code to delete all rows beneath and columns right of pivot table klysell Excel Programming 3 February 7th 08 06:46 PM
How to delete extra rows from bottom? Lentenrose Excel Discussion (Misc queries) 1 November 10th 06 05:23 PM
Delete extra rows at the end of macro run jmatchus Excel Programming 0 January 21st 04 08:50 PM


All times are GMT +1. The time now is 11:48 PM.

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

About Us

"It's about Microsoft Excel"