Results 1 to 9 of 9

Thread: Need help with a delete macro
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Feb 2019
    Posts
    138
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Need help with a delete macro

    Hi Everyone,

    I have a worksheet with close to 1000 rows. I want to delete ALL rows where the VALUE in Column A DOES NOT
    BEGIN with ZERO with a macro.

    Any help would be appreciated!

    Thank you!

  2. #2
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    28,362
    Post Thanks / Like
    Mentioned
    471 Post(s)
    Tagged
    47 Thread(s)

    Default Re: Need help with a delete macro

    Is col A text, or numbers that are formatted to show leading 0s
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  3. #3
    Board Regular
    Join Date
    Feb 2019
    Posts
    138
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Need help with a delete macro

    Hi Fluff,

    They are text.

    Thank you!

  4. #4
    Board Regular
    Join Date
    Feb 2019
    Posts
    138
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Need help with a delete macro

    Fluff,

    I think I got it if this looks correct to you?

    Code:
    With Range("A2", Range("A" & Rows.Count).End(xlUp))     
     .Value = Evaluate(Replace("if(left(@,1)=""0"",@,"""")", "@", .Address))
          .SpecialCells(xlBlanks).EntireRow.Delete
       End With
    Last edited by Buns1976; May 11th, 2019 at 10:52 AM.

  5. #5
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    28,362
    Post Thanks / Like
    Mentioned
    471 Post(s)
    Tagged
    47 Thread(s)

    Default Re: Need help with a delete macro

    Does it work?
    Last edited by Fluff; May 11th, 2019 at 11:00 AM.
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  6. #6
    Board Regular
    Join Date
    Feb 2019
    Posts
    138
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Need help with a delete macro

    Hi Fluff,
    It works BUT its messing up another macro so I need to change it. Stay tuned.

    Thank you!

  7. #7
    MrExcel MVP Rick Rothstein's Avatar
    Join Date
    Apr 2011
    Location
    New Jersey, USA
    Posts
    35,252
    Post Thanks / Like
    Mentioned
    92 Post(s)
    Tagged
    33 Thread(s)

    Default Re: Need help with a delete macro

    Quote Originally Posted by Buns1976 View Post
    Hi Fluff,
    It works BUT its messing up another macro so I need to change it. Stay tuned.
    I don't see how that code could mess up another macro. If I had to guess, I'd say your other macro is not coping with the row removals correctly (possibly still using original row information against the now reduced number of rows).
    Rick's "mini" blog... http://www.excelfox.com/forum/f22/
    .
    Want to post a small screen shot? See Part B here.

  8. #8
    Board Regular
    Join Date
    Feb 2019
    Posts
    138
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Need help with a delete macro

    Hi Fluff,

    I was able to get this resolved.

    Thanks for your help!!

  9. #9
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    28,362
    Post Thanks / Like
    Mentioned
    471 Post(s)
    Tagged
    47 Thread(s)

    Default Re: Need help with a delete macro

    Glad you sorted it & thanks for the feedback
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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