+ Reply to Thread
Results 1 to 6 of 6

How do i delete with macro?

  1. #1
    Forum Contributor
    Join Date
    08-29-2006
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    314

    How do i delete with macro?

    Dear all

    On attached sheet I want to delete all the rows if it is not a date on Column A with a macro?

    Can you please help how to write it?

    please see attached

    Many thanks
    Attached Files Attached Files

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: How do i delete with macro?

    based on your sample file it may be easier to base the deletion on F given these are seemingly only non-blank where the value in A is a date, eg:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-10-2009
    Location
    Antalya, Turkey
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: How do i delete with macro?

    You may use this macro below...


    Sub DeleteRow_if_it_is_not_Date()
    Dim A_Value As Boolean

    Range("A65536").Select
    Selection.End(xlUp).Select
    i = ActiveCell.Row

    For r = i To 1 Step -1
    If Not IsDate(Cells(r, 1).Value) Then

    Rows(r & ":" & r).EntireRow.Delete
    End If
    Next r

    End Sub
    Last edited by Atila Akal; 08-10-2009 at 12:04 PM.

  4. #4
    Forum Contributor
    Join Date
    08-29-2006
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    314

    Re: How do i delete with macro?

    Thanks mate ,it worked.

  5. #5
    Forum Contributor
    Join Date
    08-29-2006
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    314

    Re: How do i delete with macro?

    They both have worked. Thank you again for all the reply.

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: How do i delete with macro?

    No problem, using SpecialCells will be faster than Iterating the range.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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