+ Reply to Thread
Results 1 to 14 of 14

Removing Blank Cells Resulting From Formula

  1. #1
    Registered User
    Join Date
    06-07-2011
    Location
    boston, ma
    MS-Off Ver
    Excel 2003
    Posts
    22

    Removing Blank Cells Resulting From Formula

    Hello. This is my first time posting for a VB question. What I am looking to do is create a code that will scan a designated range and remove any blank rows. These blank rows are a result of a formula that I created from an =IF statement leaving a " " if it was false. Is there a way to remove these blank rows and possibly even shift the cells up?

    A B C D E
    1 ! ! ! ! !
    2
    3@ @ @ @ @
    4# # # # #
    5

    In this example, numbers were just replaced with random symbols, but what I would like to have happen is have rows 2 and 5 removed and have the data shifted up.

    Is this possible? Thank you.

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Removing Blank Cells Resulting From Formula

    Assuming your list of data is in A1:A20, this would do it:

    Please Login or Register  to view this content.
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Registered User
    Join Date
    06-07-2011
    Location
    boston, ma
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: Removing Blank Cells Resulting From Formula

    Quote Originally Posted by davegugg View Post
    Assuming your list of data is in A1:A20, this would do it:

    Please Login or Register  to view this content.
    Using this code, I was able to remove any cells that were just empty...It did not take out any cells that were blank resulting from a formula. You can see in the attached file that I have a very basic =IF statement for some cells causing them to return " ". Can these cells/rows be removed as well, or can it only be the ones that are truly blank and empty?
    Attached Files Attached Files

  4. #4
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Removing Blank Cells Resulting From Formula

    Can you change the formula to make the cells empty:

    =If(True=True,"","Otherwise")

  5. #5
    Registered User
    Join Date
    06-07-2011
    Location
    boston, ma
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: Removing Blank Cells Resulting From Formula

    Quote Originally Posted by davegugg View Post
    Can you change the formula to make the cells empty:

    =If(True=True,"","Otherwise")
    I changed the formula around and made the cell blank if the result was true and had it display a value if it was false. Running the code did not remove these cells.

  6. #6
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Removing Blank Cells Resulting From Formula

    Shoot, you're right. Unfortunately, you'll have to loop through the cells. It'll take a bit longer, but it'll do what you want:

    Please Login or Register  to view this content.
    This will run from the last used row in column A to the first row in column A.

  7. #7
    Registered User
    Join Date
    06-07-2011
    Location
    boston, ma
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: Removing Blank Cells Resulting From Formula

    Hey Dave,

    I ran the code you gave me, and it didn't seem to remove any of the cells in the list. Is there anything in that code that I need to change to work for the spreadsheet I am using?

  8. #8
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Removing Blank Cells Resulting From Formula

    Are the blank cells in column A? Are the blank cels = "" or " "?

  9. #9
    Registered User
    Join Date
    06-07-2011
    Location
    boston, ma
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: Removing Blank Cells Resulting From Formula

    Quote Originally Posted by davegugg View Post
    Are the blank cells in column A? Are the blank cels = "" or " "?
    In the spreadsheet I am testing this with, the blank cells are in column A. The blank cells are the result of the formula with "" and not " ".

    Optimally, if possible, I would like to use this to run within a specified range.

  10. #10
    Registered User
    Join Date
    06-07-2011
    Location
    boston, ma
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: Removing Blank Cells Resulting From Formula

    I'm not exactly sure how to do this, but would it make sense to have a macro in place to search for cells that returned "" and clear all their contents (hopefully removing the formulas) and then running the other macro you supplied earlier to remove blank wells?

  11. #11
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Removing Blank Cells Resulting From Formula

    This for a specified range:

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    06-07-2011
    Location
    boston, ma
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: Removing Blank Cells Resulting From Formula

    Quote Originally Posted by davegugg View Post
    This for a specified range:

    Please Login or Register  to view this content.
    Works perfectly!! Thank you so much for the help.

  13. #13
    Registered User
    Join Date
    06-09-2011
    Location
    Dallas
    MS-Off Ver
    Excel 2003
    Posts
    2

    Question Searching a words in a cell and returning closest match in a lookup table

    I am trying to use one or two words in a cell (column named "Model") and then use that to return the closest matching cell in a lookup table (Column "Activity"). In most cases, only one word in the column "Model" is present in the column "Activity".

    I have attached a template sheet the output column with one example of the ideal output.

    I appreciate you help.
    Thanks in advance!
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    04-20-2012
    Location
    Hong Kong
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Removing Blank Cells Resulting From Formula

    Hi Davegug
    It's rather late but I must thank you for this tip. I had been looking for a similar solution. Thanks a lot.


    Quote Originally Posted by davegugg View Post
    This for a specified range:

    Please Login or Register  to view this content.

+ 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