ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deleting rows when a certain cell has a certain value (https://www.excelbanter.com/excel-programming/370632-deleting-rows-when-certain-cell-has-certain-value.html)

Leentje[_2_]

Deleting rows when a certain cell has a certain value
 

Hi,

Can someone help me with the next problem?
I would like to create a Macro which deletes the line if the date value
in a certain column is in the past.

Thanks for your feedback,

Leentje


--
Leentje
------------------------------------------------------------------------
Leentje's Profile: http://www.excelforum.com/member.php...o&userid=37223
View this thread: http://www.excelforum.com/showthread...hreadid=572528


Simon Lloyd[_884_]

Deleting rows when a certain cell has a certain value
 

Hi paste this code in to the worksheet module, every time the sheet i
activated it will search through the specified range and delet
everything older than today!

Hope it helps.

Regards,
Simon

Option Explicit

Private Sub Worksheet_Activate()
Dim mycell
Dim rng As Range
Set rng = Range("A1:A100")
For Each mycell In rng
If mycell.Value < Date Then
Application.ScreenUpdating = False
mycell.EntireRow.Delete
End If
Next
Application.ScreenUpdating = True
End Su

--
Simon Lloy
-----------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...nfo&userid=670
View this thread: http://www.excelforum.com/showthread.php?threadid=57252


Leentje[_3_]

Deleting rows when a certain cell has a certain value
 

When executing this macro, the odd lines are not checked.
When executing the macro again various times the final result is ok.
So I think I need to add some additional code to solve this...
Can you help

--
Leentj
-----------------------------------------------------------------------
Leentje's Profile: http://www.excelforum.com/member.php...fo&userid=3722
View this thread: http://www.excelforum.com/showthread.php?threadid=57252



All times are GMT +1. The time now is 10:54 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com