+ Reply to Thread
Results 1 to 7 of 7

Delete Rows Based on Time criteria

Hybrid View

Roelandu Delete Rows Based on Time... 01-30-2012, 06:58 AM
Domski Re: Delete Rows Based on Time... 01-30-2012, 07:19 AM
Roelandu Re: Delete Rows Based on Time... 01-30-2012, 09:38 AM
Domski Re: Delete Rows Based on Time... 01-30-2012, 09:57 AM
Roelandu Re: Delete Rows Based on Time... 01-30-2012, 10:43 AM
rvkadu1 Re: Delete Rows Based on Time... 09-26-2012, 08:01 AM
arlu1201 Re: Delete Rows Based on Time... 09-26-2012, 08:07 AM
  1. #1
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Delete Rows Based on Time criteria

    Try this:

    Sub Delete_rows()
        Dim i As Long
        With Sheets("New")
            For i = .Cells(Rows.Count, "A").End(xlUp).Row To 2 Step -1
                If .Cells(i, "V") > TimeSerial(23, 0, 0) Or Cells(i, "V") < TimeSerial(8, 0, 0) Then
                    .Rows(i).Delete
                End If
            Next i
        End With
    End Sub
    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  2. #2
    Registered User
    Join Date
    01-30-2012
    Location
    Hasselt, Belgium
    MS-Off Ver
    Excel 2011 for Mac
    Posts
    4

    Re: Delete Rows Based on Time criteria

    Thanks Dom. When i apply this code, it deletes everything but row 1 (the header). I think the OR operator
    is not the best one anyway because both conditions (>23h and <8h) need to be fulfilled, so i'd rather go for AND even
    though that doesn't work either.

    I'm quite desperate, i've been trying stuff for hours but i can seem to make it work
    I'm definitly not an expert in this kind of codes.

    Any help is welcome!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1