+ Reply to Thread
Results 1 to 6 of 6

Macro for removing rows of empty cells within a spreadsheet

  1. #1
    Registered User
    Join Date
    11-29-2013
    Location
    Taunton, England
    MS-Off Ver
    Excel 2007
    Posts
    6

    Macro for removing rows of empty cells within a spreadsheet

    Hi,

    Novice Excel user who needs help with hopefully a simple problem.

    The attached file is a portion of my original which is far too large to upload but should show my issue. It shows an area of cells within my spreadsheet which are automatically populated from other cells in the workbook.

    The idea is that at the end of the week once the data has been gathered it can be copied and pasted directly into another piece of software. Unfortunately because there is blank rows of cells between the data it will only paste the first block of numbers.

    Is there a simple macro that can identify the empty rows within a set area of cells (blue area B4 to K78), strip them out and move the data up? Additionally I'd require a macro to reset the cells back again once the copy and paste had been completed.

    The important bit to add is that on the original spreadsheet there is numerous other data/formulas alongside this area therefore the macro won't be able to strip out an entire row but just the row of cells within the blue area shown.

    Any help gratefully appreciated.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: Macro for removing rows of empty cells within a spreadsheet

    For each row that is empty in column B, this would work:

    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: Macro for removing rows of empty cells within a spreadsheet

    In this instance, since many of the rows I believe you want do delete in fact contain the value 0, a loop with step-1 would work:

    Please Login or Register  to view this content.

  4. #4
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Macro for removing rows of empty cells within a spreadsheet

    @ berlan,

    The important bit to add is that on the original spreadsheet there is numerous other data/formulas alongside this area therefore the macro won't be able to strip out an entire row but just the row of cells within the blue area shown.
    I don't think deleting entire Rows would work in this case.

    My approach would be to filter out the "Blanks" in a specified range, Copy and Paste the results and then clear the filter where the original data has to be restored.

    Regards
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  5. #5
    Valued Forum Contributor
    Join Date
    03-21-2013
    Location
    cyberia
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Macro for removing rows of empty cells within a spreadsheet

    for genuinely empty rows, here's a code that should do as you ask.

    it only operates on rows within the range B4:K78

    however, most of your apparently empty rows in your sample file aren't really empty; they contain zeros and ??. so ??
    Please Login or Register  to view this content.
    I guess I should add that the approach you outline, and which the above code follows, seems a rather inefficient way to resolve the problem.
    Last edited by kalak; 11-30-2013 at 06:28 AM.

  6. #6
    Registered User
    Join Date
    11-29-2013
    Location
    Taunton, England
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Macro for removing rows of empty cells within a spreadsheet

    Thanks for all the advice given. On the basis of what's been said I've made some alterations to my worksheet.

    The area of data I wanted to remove rows of cells from has now been transferred to another worksheet so it doesn't interfere with any other formulas nearby. This has allowed me to create a macro to remove entire rows.

    In the first column where the cells had no data but just zeros I added a filter to remove those which subsequently deleted the empty rows. The macro was set up on the basis of this and subsequently could be setup in reverse to reinstate the rows.

    Thanks again for the help.

+ 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. Macro code to past cells from a different spreadsheet to next empty cell
    By glock9mm in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-23-2013, 02:38 AM
  2. Removing empty rows
    By sentinela in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-03-2010, 11:10 AM
  3. Removing empty rows with a macro
    By Mikie in forum Excel General
    Replies: 8
    Last Post: 10-12-2009, 06:15 PM
  4. Removing empty rows?
    By frenchman96 in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 09-24-2007, 11:42 AM
  5. Removing Empty Rows and selecting Specific Rows
    By Jetheat in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-11-2005, 07:10 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