LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 84
Default Delete all rows not today

Sorry about that, try this modified code:

Sub DelNotTodayRows()
'Deletes rows where the value in column F is not today's date
Dim RowNdx As Long
Dim LastRow As Long

LastRow = Cells(Rows.Count, "F").End(xlUp).Row

For RowNdx = LastRow To 1 Step -1

If Cells(RowNdx, "F").Value = FormatDateTime(Now, vbShortDate) =
False Then
Rows(RowNdx).Delete
End If

Next RowNdx

End Sub

"SITCFanTN" wrote:

Oops Paul, maybe I'm doing this the wrong way...I only want to keep rows with
the current date....this code deletes the current date rows. Should I relook
at this and delete all rows not the current date? What is the best option?

"Paul Mathews" wrote:

Sub DelTodayRows()
'Deletes rows where the value in column F is today's date
Dim RowNdx As Long
Dim LastRow As Long

LastRow = Cells(Rows.Count, "F").End(xlUp).Row

For RowNdx = LastRow To 1 Step -1

If Cells(RowNdx, "F").Value = FormatDateTime(Now, vbShortDate) =
True Then
Rows(RowNdx).Delete
End If

Next RowNdx

End Sub

"SITCFanTN" wrote:

Can somebody please help me with this code, I'm trying to delete all rows
that are not dated the current date. My date format in column F is
mm/dd/yyyy, do I need to state that. Thanks

LastRow = Cells(Rows.Count, "F").End(xlUp).Row
For RowNdx = LastRow To 1 Step -1
If StrComp(Cells(RowNdx, "F"), =Today(), vbTextCompare) < 0 Then
Rows(RowNdx).Delete
End If
Next RowNdx



 
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
Hpw do I delete multiple empty rows found between filled rows? Bill Excel Worksheet Functions 2 November 15th 09 07:12 PM
Cut filtered rows, paste into next empty row of new sheet, and delete cut rows Scott Excel Worksheet Functions 0 December 13th 06 01:25 AM
Delete rows with numeric values, leave rows with text GSpline Excel Programming 5 October 11th 05 12:44 AM
How to delete rows when List toolbar's "delete" isnt highlighted? Linda Excel Worksheet Functions 1 May 26th 05 08:39 PM
Delete every 3rd row, then delete rows 2-7, move info f/every 2nd row up one to the end and delete the row below Annette[_4_] Excel Programming 2 September 21st 04 02:40 PM


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