Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Range / Deleting Selection

Status
Not open for further replies.

sabascal

IS-IT--Management
Aug 20, 2002
85
GB
Hi all,

Could you help me on the following.
1) Given a range called R1 how can I delete the last p rows (entire row)
Thks Seb
 
Hi Seb,

This should do it:

Code:
If p > R1.Rows.Count Then
    R1.EntireRow.Delete
Else
    Range(R1(R1.Rows.Count - p + 1, 1), R1(R1.Rows.Count, 1)).EntireRow.Delete
End If

but I can't help feeling there's a slicker way.

Enjoy,
Tony
 
I tried to run the following simple procedure to make it more efficient: for some reason I keep getting errors:
"Application Defined or Object defined Error"
Any idea why? any quick fix?


Sub test()
Worksheets("test").Activate
Range(Cells(1, 1), Cells(7, 7)).Select
Selection.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End Sub

PS: the 1st 2 lines run fine problem is with the delete statment.

Cheers,
Seb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top