+ Reply to Thread
Results 1 to 6 of 6

Remove empty rows based on a cell range.

  1. #1
    Forum Contributor
    Join Date
    10-13-2011
    Location
    Australia
    MS-Off Ver
    Office 16
    Posts
    329

    Remove empty rows based on a cell range.

    Is there a way to remove empty rows, by selecting a specific range of rows only.
    In the attached sheet, the range is Rows $A$20 to $A$45 inclusive, but it must start at row 20.
    If the code can be limited to the range stipulated only, if empty they will remove the row, stopping at row 46 - which contains data.

    So it checks the row, if populated move to the next row, if populated move to the next row, and so on until it finds an empty cell in column A, then deletes the row and continues down until the last empty row in the range inclusive of $A$45.
    Attached Files Attached Files
    Last edited by Christopherdj; 06-09-2020 at 06:14 PM.

  2. #2
    Registered User
    Join Date
    05-14-2020
    Location
    Mauritius
    MS-Off Ver
    Office 365
    Posts
    97

    Re: Remove empty rows based on a cell range.

    Hello,

    this is something easy. But it is to say that with VBA the deletion of rows should be done from bottom to top.
    Here a short code which works for your requirements:

    Please Login or Register  to view this content.
    Greetings

    Tor


  3. #3
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    777

    Re: Remove empty rows based on a cell range.

    Or maybe you can try this :

    Please Login or Register  to view this content.
    The code above will delete the entire row (within row 20 to 45) which has no value/blank.

  4. #4
    Forum Contributor
    Join Date
    10-13-2011
    Location
    Australia
    MS-Off Ver
    Office 16
    Posts
    329

    Re: Remove empty rows based on a cell range.

    Thank you, I understand your comment bottom to top, it makes sense to work that way.
    Karmapala's response is simpler and keeps it to the range as well.

  5. #5
    Forum Contributor
    Join Date
    10-13-2011
    Location
    Australia
    MS-Off Ver
    Office 16
    Posts
    329

    Re: Remove empty rows based on a cell range.

    Your code is great thanks.

  6. #6
    Registered User
    Join Date
    05-14-2020
    Location
    Mauritius
    MS-Off Ver
    Office 365
    Posts
    97

    Re: Remove empty rows based on a cell range.

    Karmapala's response is simpler and keeps it to the range as well.
    Yes it is shorter.
    And by the way my code keeps the range also. But I was checking before for the last used row. So the range is more flexible in case the range change.
    No matter it will be shorter or longer. With my code you do not need to amend the range in the code. This just for info.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Hide Rows Based on Empty Cell
    By YSL in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-05-2019, 10:57 AM
  2. Add/remove rows to a range based on filter rows of another range
    By Jubinell in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-01-2017, 07:06 AM
  3. Copy filtered Range, Remove Filter, Find 1st Empty Cell from the bottom, Paste VBA
    By intervals in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-29-2016, 10:48 PM
  4. VBA how to remove rows based on a specified date range
    By clammastak in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-15-2015, 03:09 PM
  5. Hiding rows based on an empty cell
    By jawnmallon in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-24-2015, 02:07 PM
  6. MACRO to empty a range of cells based on whether specified cell is empty
    By TBJV in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-01-2013, 10:35 PM
  7. Hide/Unhide a range of rows when cell is empty
    By chuck edwards in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-10-2012, 04:25 PM

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