×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

How to eliminate cells that are before 3:00 PM

How to eliminate cells that are before 3:00 PM

How to eliminate cells that are before 3:00 PM

(OP)
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?

RE: How to eliminate cells that are before 3:00 PM

Try this:

Sub DeleteRow()
    Dim iRow As Integer
        
    iRow = 1
    While Cells(iRow, 1) <> ""
        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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources