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: 11
Default Excel 2003 - Macro for deleting rows

Greetings,

I'm using Excel 2003 to do some deleting and sorting of a monthly list and
I'd like to automate most, if not all, of it.

Ideally, I'd want Excel to search through column D for a certain text entry
and delete any row that contains this text.

I would also like it to only search rows with data (anywhere from 50 to
about 3,000), but I'm sure searching the entire column won't be a big deal.

My difficulty seems, at this point, to be that I can't get the row to
delete. When I ran the macro, it deleted ALL rows, so I changed it to
Rows.Select and it selected ALL rows.

I can't seem to get Row.Delete (or Row.Select) to work on just the row where
the entry was found.

Here's what I've got so far:

Dim t As Range
Set t = Range("D2:D3000")
For Each D In t
If D.Value = Worksheets("Sheet2").Range("A1") Then Rows.Delete
Next

It works, if I want to delete ALL rows (Select and Activate work as well).

I've never tried to get Excel to go to the last row with data and somehow
'record' the row number, much less use that to set a range, but I'd really
like to find a way to delete just one row based on the content of one of its
cells.

Any ideas?

Thanks,

Solon


 
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
Excel 2003 - deleting trailing empty rows ICTag New Users to Excel 5 July 17th 09 06:05 PM
Subtotals Deleting Rows after removing Subtotal - 2003 Excel Raul[_2_] Excel Worksheet Functions 1 October 2nd 07 06:28 PM
Microsoft Excel 2003 - Deleting rows FLYNNE Excel Discussion (Misc queries) 2 April 5th 07 03:28 PM
Deleting Rows in Excel 2003 Gilbert Excel Discussion (Misc queries) 3 March 16th 07 01:44 AM
Excel 2003; spreadsheet with filtering; deleting rows MHcoTech Excel Worksheet Functions 0 September 6th 06 01:33 AM


All times are GMT +1. The time now is 06:45 AM.

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"