Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7
Default How to create a macro to delete multiple rows?

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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7,247
Default How to create a macro to delete multiple rows?

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)


"gak27" wrote in message
...
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


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default How to create a macro to delete multiple rows?

maybe

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

Mike

"gak27" wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default How to create a macro to delete multiple rows?

This is a one-liner:

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

--
Gary''s Student - gsnu200762


"gak27" wrote:

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

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7
Default How to create a macro to delete multiple rows?

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

"gak27" wrote:

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

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
Delete Blank Rows Code - Multiple Worksheets - Multiple Documents BenS Excel Discussion (Misc queries) 3 June 29th 07 12:20 AM
Macro to Delete Certain Rows HROBERTSON Excel Discussion (Misc queries) 2 February 8th 07 09:42 PM
Create a macro to delete rows if value is less than a specified nu QE Excel Worksheet Functions 5 July 27th 06 08:35 PM
create macro - if cell is 0 delete row pywhacket Excel Worksheet Functions 1 March 15th 06 03:55 PM
delete rows-macro TUNGANA KURMA RAJU Excel Discussion (Misc queries) 5 January 13th 06 12:01 PM


All times are GMT +1. The time now is 10:17 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"