Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Entirerow.delete based on multiple cells

I need to delete entire rows if the date of cells in rows ab, ac, ad
adn ar are before Dec 1, 2005.

I can do a delete based on the contents of a single cell easily enough,
but this throws me.

For example:
ab ac ad ae
------------------------------------------------
12/2/05 | 11/5/05 | 11/3/05 | 11/30/05
11/30/05 | 11/1/05 | 11/5/05 | 11/5/05

I would like the routine to delete the second row, since all dates are
before 12/1/05, but leave
the first row intact since at least one date is after 12/1/05. Of
course, the live spreadsheet includes more than just two rows.

Any help would be greatly appceciated.

Thanks

-tom

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Entirerow.delete based on multiple cells

Dim dt as Date
Dim lastrow as Long
Dim i as Long
set dt = DateSerial(2005,12,1)
lastrow = cells(rows.count,"ab").end(xlup)
for i = lastrow to 2 step -1
if cells(i,"ab).Value < dt and _
cells(i,"ac").Value < dt and _
cells(i,"ad").Value < dt and _
cells(i,"ae").Value < dt then
rows(i).Delete
end if
Next

--
Regards,
Tom Ogilvy


"tom" wrote in message
ups.com...
I need to delete entire rows if the date of cells in rows ab, ac, ad
adn ar are before Dec 1, 2005.

I can do a delete based on the contents of a single cell easily enough,
but this throws me.

For example:
ab ac ad ae
------------------------------------------------
12/2/05 | 11/5/05 | 11/3/05 | 11/30/05
11/30/05 | 11/1/05 | 11/5/05 | 11/5/05

I would like the routine to delete the second row, since all dates are
before 12/1/05, but leave
the first row intact since at least one date is after 12/1/05. Of
course, the live spreadsheet includes more than just two rows.

Any help would be greatly appceciated.

Thanks

-tom



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Entirerow.delete based on multiple cells

Thanks, but can you tell me why I get a "type mismatch" on this
statement:

Dim lastrow As Long
lastrow = Cells(Rows.Count, "ar").End(xlUp)

??

Thanks

-tom

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Entirerow.delete based on multiple cells

Must be

lastrow = Cells(Rows.Count, "a").End(xlUp)



--
Regards Ron de Bruin
http://www.rondebruin.nl


"tom" wrote in message ups.com...
Thanks, but can you tell me why I get a "type mismatch" on this
statement:

Dim lastrow As Long
lastrow = Cells(Rows.Count, "ar").End(xlUp)

??

Thanks

-tom



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Entirerow.delete based on multiple cells

Nevermind - you were missing the .row, i.e.

Dim lastrow As Long
lastrow = Cells(Rows.Count, "ar").End(xlUp) .ROW

Thanks for your help.

-tom



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Entirerow.delete based on multiple cells

Ahhhaaa

indeed .row

I believe it is bed time before I post more stupid things <g


--
Regards Ron de Bruin
http://www.rondebruin.nl


"tom" wrote in message ups.com...
Nevermind - you were missing the .row, i.e.

Dim lastrow As Long
lastrow = Cells(Rows.Count, "ar").End(xlUp) .ROW

Thanks for your help.

-tom



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
Need Help with ActiveCell.EntireRow.Delete Ayo Excel Discussion (Misc queries) 4 July 20th 08 11:07 AM
Need Help with ActiveCell.EntireRow.Delete Ayo Excel Discussion (Misc queries) 8 July 19th 08 04:45 PM
How to fix cell.entirerow.delete? guy Excel Programming 1 March 10th 05 02:31 AM
EntireRow.Delete Steph[_3_] Excel Programming 14 January 21st 05 10:31 PM
entirerow.delete multiple text conditions Jocelyn[_3_] Excel Programming 3 February 9th 04 05:58 PM


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