Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

How to eliminate cells that are before 3:00 PM

Status
Not open for further replies.

aordoqui

Computer
Jan 12, 2003
3
I have a question regarding microsoft excel using Visual Basic. I have a worksheet that has a list of activities sorted by "time" which is the first column, the other columns hold other information such as "company" and "name." I want to delete the lines of information that happen before 3:00 PM.

The report looks like the following
TIME COMPANY NAME
7:00 TWP Tony
8:30 CPI Aaron
15:30 FGI Frank
16:00 WTI Anthony

How do I get rid of the two lines before 3pm using Visual Basic Code?
 
Replies continue below

Recommended for you

Try this:
Code:
Sub DeleteRow()
    Dim iRow As Integer
        
    iRow = 1
    While Cells(iRow, 1) <> &quot;&quot;
        If Cells(iRow, 1).Value < TimeSerial(15, 0, 0) Then
            Rows(iRow).Select
            Selection.Delete Shift:=xlUp
        Else: iRow = iRow + 1
        End If
    Wend
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor