How to create a macro to delete multiple rows?

  • Thread starter Thread starter gak27
  • Start date Start date
G

gak27

Greetings!

This question is for Excel 2007.

I am working with data sets that have many rows of data and I only need a
few of them. What I would like to do is create a macro that will delete 100
rows from my worksheet, starting where I place the cursor. What is the best
way to do this? Whenever I try to record the macro and use it I always wind
up having the 100 rows being deleted from the same location, but I need to
move down through the entire spreadsheet.

greg
 
You can delete multiple rows with code like

ActiveCell.Resize(100, 1).EntireRow.Delete

This code will delete entire rows starting with the active cell down to row
number ActiveCell.Row + 99.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)
 
maybe

Sub addhpb()
ActiveCell.EntireRow.Select
Set MyRange = Selection.Resize(100)
MyRange.Delete
End Sub

Mike
 
This is a one-liner:

Sub ordinate()
Range(ActiveCell, ActiveCell.Offset(99, 0)).EntireRow.Delete
End Sub
 
Thanks! I'll try all of the suggestions. Sorry for the multiple post of
this subject above...
 
Back
Top