ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deleting dates (https://www.excelbanter.com/excel-programming/353661-deleting-dates.html)

ebraun01[_11_]

Deleting dates
 

I'm hoping this is simple one for one of you guru's. I'm looking for a
macro that will search multiple columns and clear any cell that has
today's date or older in it. Format of the date is 02-1-06 and
02-31-06. In other words, the day is not always two digits.


--
ebraun01
------------------------------------------------------------------------
ebraun01's Profile: http://www.excelforum.com/member.php...o&userid=30340
View this thread: http://www.excelforum.com/showthread...hreadid=513863


Leith Ross[_551_]

Deleting dates
 

Hello Ebraun01,

Try this macro...

Sub ClearDates()

Dim Cell As Range

For Each Cell In ActiveSheet.UsedRange
If VarType(Cell) = vbDate Then
If Cell.Value <= Int(Now) Then Cell.ClearContents
End If
Next Cell

End Sub

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=513863


ebraun01[_12_]

Deleting dates
 

If I have a cell that only has a date, then it works but if the cell as
additional text in it, it doesnt. The macro needs to search all cells
and remove any that have dates older than today. An example of a date
is below. In this example I would want it to clear the cell with the
Lysol Spray. Hope that is more clear and thanks for the help.

Nabisco Crackers (2-26-06)
Lysol Disinfectant Spray (2-1-06)
Glade Spray (4-15-06)


--
ebraun01
------------------------------------------------------------------------
ebraun01's Profile: http://www.excelforum.com/member.php...o&userid=30340
View this thread: http://www.excelforum.com/showthread...hreadid=513863


Leith Ross[_552_]

Deleting dates
 

Hello Ebraun01,

Will the dates always be in parathesis? Will the day, month, and year
always be separated by hyphens?. As long as some aspects of the format
are constant, it won't be to difficult to adapt the code. Let me know.

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=513863


ebraun01[_13_]

Deleting dates
 

Yes, thanks for the clarification. The dates are all in parenthesis and
hyphens.


--
ebraun01
------------------------------------------------------------------------
ebraun01's Profile: http://www.excelforum.com/member.php...o&userid=30340
View this thread: http://www.excelforum.com/showthread...hreadid=513863



All times are GMT +1. The time now is 12:20 AM.

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