How to create a macro to delete multiple rows?

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
 
C

Chip Pearson

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)
 
M

Mike H

maybe

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

Mike
 
G

Gary''s Student

This is a one-liner:

Sub ordinate()
Range(ActiveCell, ActiveCell.Offset(99, 0)).EntireRow.Delete
End Sub
 
G

gak27

Thanks! I'll try all of the suggestions. Sorry for the multiple post of
this subject above...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top