+ Reply to Thread
Results 1 to 8 of 8

Delete Rows FROM "X" UNTIL "Y" appears

Hybrid View

  1. #1
    Registered User
    Join Date
    10-19-2012
    Location
    Rj
    MS-Off Ver
    Excel 2007
    Posts
    6

    Question Delete Rows FROM "X" UNTIL "Y" appears

    Hello VBA partners, i need help with a sub rather easy.

    I need one that do that, with this data:

    Column A

    10068
    blank
    blank
    blank
    blank
    10069

    i need a sub that deletes the entire row FROM 10068 until 10069 (the row with 10069 is not meant to be deleted)

    I hope you can help me, and i hope i can retribute someday, when i have more experience.

    Att,

    Mario Tinoco

  2. #2
    Valued Forum Contributor Miraun's Avatar
    Join Date
    04-03-2009
    Location
    New England
    MS-Off Ver
    2003, 2007, 2010, 2013
    Posts
    554

    Re: Delete Rows FROM "X" UNTIL "Y" appears

    Definitely not the prettiest way to do it, but here's a version for you:

    Sub deleterows()
    Range("A1").Activate
    Do Until ActiveCell.Value = 10068
    ActiveCell.Offset(1, 0).Activate
    Loop
    ActiveCell.Offset(1, 0).Activate
    Do Until ActiveCell.Value = 10069
    ActiveCell.EntireRow.delete
    Loop
    End Sub
    Going for Guru! Click the Star to the bottom left of this post if I helped!

  3. #3
    Registered User
    Join Date
    10-19-2012
    Location
    Rj
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Delete Rows FROM "X" UNTIL "Y" appears

    Man, thanks for the ultra-fast answer.

    It's ALMOST perfect, just because i need it to delete the row with "10068". All the rest is perfect and will help me a lot in my work here. Really, really thank you.

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Delete Rows FROM "X" UNTIL "Y" appears

    So its not only the blanks that should be deleted?

    Why dont you show us a little bigger sample of your data so we can make a better fool-proof code for you?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  5. #5
    Valued Forum Contributor Miraun's Avatar
    Join Date
    04-03-2009
    Location
    New England
    MS-Off Ver
    2003, 2007, 2010, 2013
    Posts
    554

    Re: Delete Rows FROM "X" UNTIL "Y" appears

    Easy fix!

    Sub deleterows()
    Range("A1").Activate
    Do Until ActiveCell.Value = 10068
    ActiveCell.Offset(1, 0).Activate
    Loop
    Do Until ActiveCell.Value = 10069
    ActiveCell.EntireRow.delete
    Loop
    End Sub

  6. #6
    Registered User
    Join Date
    12-07-2012
    Location
    Dallas
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Delete Rows FROM "X" UNTIL "Y" appears

    Is there a way to have this loop through the entire sheet? if there were multiple sets of the 10068 and 10069 further down the sheet?

  7. #7
    Registered User
    Join Date
    10-19-2012
    Location
    Rj
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Delete Rows FROM "X" UNTIL "Y" appears

    It's more than perfect now, that was just my need. I appreciate very much the help and attention (sorry for the messy english).

    i think i'll need help soon, with some sending charts on e-mail body, but that's another chapter.

    I will set as solved and give you stars.

    Thanks again!

  8. #8
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: Delete Rows FROM "X" UNTIL "Y" appears

    Sorry, my bad.
    Last edited by Trebor76; 12-08-2012 at 07:49 PM.
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

+ 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