+ Reply to Thread
Results 1 to 10 of 10

CurrentRegion.EntireRow.Delete (+ the next row)

  1. #1
    Registered User
    Join Date
    12-15-2011
    Location
    Charleston, SC
    MS-Off Ver
    Excel 2010
    Posts
    43

    CurrentRegion.EntireRow.Delete (+ the next row)

    The following code work great. However, after running the macro, I still have to go back and delete another row for each region that was delete.

    My question is... what code would allow for the region to be deleted along with the very next row?

    Please Login or Register  to view this content.
    Last edited by BBoydAnchor; 12-28-2011 at 03:21 PM.

  2. #2
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: CurrentRegion.EntireRow.Delete (+ the next row)

    Hi,

    I think you are looking for Resize

    Please Login or Register  to view this content.
    abousetta
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: CurrentRegion.EntireRow.Delete (+ the next row)

    Hello BBoydAnchor,

    This will delete the very next line, which should be blank, after the last line of the region. You should stay away from using On Error Resume Next and check if the Range object was set.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: CurrentRegion.EntireRow.Delete (+ the next row)

    This can not handle if you have multiple values of the same.

    Try this:
    Please Login or Register  to view this content.
    Steffen Thomsen
    Please take time to read the forum rules

  5. #5
    Registered User
    Join Date
    12-15-2011
    Location
    Charleston, SC
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: CurrentRegion.EntireRow.Delete (+ the next row)

    All the code provided did not work as I need it to, but I really appreciate the time each of you put forth to help me out. I have enough to make my job easier each month so I am happy.

    I have attached a sample spreadsheet along with my Macro Workbook with steps I take in this process. A lot of the code was recorded macros to begin with and the others were a combination of code people here on this forum helped with and from watching videos on Lynda.com.

    If anyone wants to look through this mess and provide any tips, that would be great, but can survive with what I have so far.

    Thanks again!
    Attached Files Attached Files

  6. #6
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: CurrentRegion.EntireRow.Delete (+ the next row)

    Using Leith's approach of setting the range first, try this instead of Sub DeleteGroups3()

    Please Login or Register  to view this content.
    abousetta

  7. #7
    Registered User
    Join Date
    12-15-2011
    Location
    Charleston, SC
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: CurrentRegion.EntireRow.Delete (+ the next row)

    Quote Originally Posted by abousetta View Post
    Using Leith's approach of setting the range first, try this instead of Sub DeleteGroups3()
    Thank you so much. This works great and helps out my process tremendously. It is amazing how just 2 characters can make a difference in code. I'm down to just 3 macros to run with some minor issues to resolve.

    What use to take me 2-3 hours to manually create these reports, now it appears I will be able do it in less than 10 minutes.

    Although the programming side is a little beyond me right now to help others, the help I've received here has given me enthusiasm to help others. I will just have to watch for easier questions that I can answer.

  8. #8
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: CurrentRegion.EntireRow.Delete (+ the next row)

    Glad it all worked out. Just a side-note, you can usually compress some of your lines of coding by removing selecting and removing other redundancies that are generated during recording macros. This will also add a little more efficiency to your code.

    Good luck.

    abousetta

  9. #9
    Registered User
    Join Date
    12-15-2011
    Location
    Charleston, SC
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: CurrentRegion.EntireRow.Delete (+ the next row)

    Quote Originally Posted by abousetta View Post
    Glad it all worked out. Just a side-note, you can usually compress some of your lines of coding by removing selecting and removing other redundancies that are generated during recording macros. This will also add a little more efficiency to your code.

    Good luck.

    abousetta
    Thanks for that tip. I've been doing these reports for over 5 years and it was just a few years ago that I recorded a few macros to speed up the process and then I did not look at the macros again until recently. Then a few months ago I started watching videos on Lynda.com and noticed that I could remove some of the recorded code and I have taken out a lot so far. It takes time to learn what can be removed. By coming here and asking questions and getting support, I'm learning a lot.

    Thanks again!

  10. #10
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: CurrentRegion.EntireRow.Delete (+ the next row)

    I too have a learned a great deal by asking and seeing how others code.

    Good luck.

    abousetta

+ 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