Consulting

Results 1 to 8 of 8

Thread: Solved: Date Delete

  1. #1
    VBAX Tutor
    Joined
    Dec 2009
    Posts
    295
    Location

    Solved: Date Delete

    hi

    i need some help with macro code

    how can i delete every row that contains a date meaneng if the cell in sheet1 contains a date need to delete the entaire row

    thanks

  2. #2
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Hi Oleg,

    It is hard to answer when we are asked to presume so much. We end up wasting time trying to help, only to find out that we assumed too much. Could you specify:

    Are we looking for dates in one particular column?
    If yes, which column?
    Are we starting at row 1, or is/are there header row(s)?

    Thanks,

    Mark

  3. #3
    VBAX Tutor
    Joined
    Dec 2009
    Posts
    295
    Location
    i am very sorry

    i need to start at row 1 and look every cell and if the cell contains a date delete the row

    i will try to explain better
    usualy i paste an example but i do not have it right know sorry

    thanks

  4. #4
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    No problem Oleg, I am only trying to help us in helping you better :-)

    Could you answer my other questions?

    Are we looking in only one column, and which column might that be?

    Mark

  5. #5
    VBAX Tutor
    Joined
    Dec 2009
    Posts
    295
    Location
    i put it this way:

    we are talking about only one column in this column the same date can repeate one time or more.
    the column is changing every time

    thanks for understanding

  6. #6
    VBAX Tutor
    Joined
    Dec 2009
    Posts
    295
    Location
    i wanted to explain "changing every time" i meant every time i run the macro


    thanks

  7. #7
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Quote Originally Posted by oleg_v
    i put it this way:

    we are talking about only one column in this column the same date can repeate one time or more.
    the column is changing every time

    thanks for understanding
    Wow! I am glad I asked the 'extra' questions Oleg. See, I would have assumed from your first post, that we were running up a column, and if there was 'a date', meaning ANY date, that we'd be deleting the row.

    I must get to bed for a bit, but maybe this will help a tiny bit. If I restated the problem/issue this way, would it be accurate?

    • I would like to look for a certain date in all rows of a particular column. If this certain date is found, then we need to delete the entire row.
    • I have a complication, in that, it may be a different column from time to time. Thus - I need to offer the user two choices:
      • The user needs to be able to type in a date, or pick a date.
      • The user needs to be able to specify what column to look in.
    Does that sound like an accurate portrayal?

    Mark

  8. #8
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Public Sub ProcessData()
    Dim i As Long
    Dim NumRows As Long
    Dim FirstRow As Long
    Dim rngRow As Range
    Dim cell As Range

    With ActiveSheet.UsedRange

    NumRows = .Rows.Count
    FirstRow = .Cells(1, 1).Row
    For i = NumRows To 1 Step -1

    For Each cell In .Rows(i).Cells

    If IsDate(cell.Value) Then

    cell.EntireRow.Delete
    Exit For
    End If
    Next cell
    Next i
    End With

    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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