Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting rows in Excel based on data inside 1

Status
Not open for further replies.

megpow

Technical User
Nov 21, 2003
10
US
I am looking to write an excel macro to delete rows in a sheet based on the "minute" value of the data. I have a sheet with a column that reads sort of like this :
10/20/2003 12:00
10/20/2003 12:12
10/20/2003 12:15
10/20/2003 13:00
10/20/2003 13:15
...

I'd like to delete the entire row associated with any cell having the number 12 as a minute reading, i.e. 10/20/2003 12:12 (but not 10/20/03 12:12 ... only the ones where the minute reading is a 12!)

I am stumped!
 
Hi
Summat like this should do it. Assumes your data is in Column A and starts in row 1 (ie A1)

Code:
Sub a()
Dim lRow As Long, lCnt As Long
lRow = [a65536].End(xlUp).Row
For lCnt = lRow To 1 Step -1
    If Minute(Cells(lCnt, 1).Value) = 12 Then
        Rows(lCnt).EntireRow.Delete
    End If
Next
End Sub

;-)

If a man says something and there are no women there to hear him, is he still wrong? [ponder]
The faqs ma'am, just the faqs. Get the best from these forums : faq222-2244
 
Yeh, sorry, that was a typo :) i meant to type
10/20/2003 12:12 (but not 10/20/2003 12:00)

Anyways, Loomah, your code worked perfect! Thanks for the help !
 
hehe :))

I thought that sort of prompting was not allowed ? :p

I guess as it was nto for yourself you can get away with it. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top