+ Reply to Thread
Results 1 to 12 of 12

Macro to delete cells containing a formula that results in ""

  1. #1
    Registered User
    Join Date
    08-17-2012
    Location
    home
    MS-Off Ver
    Excel 2003
    Posts
    26

    Question Macro to delete cells containing a formula that results in ""

    Hi all,
    I've googled left and right about the topic, and all I can find is macros to delete blank cells.

    In my case, I want to delete cells (within my selection) that contain a formula, and the formula results in "".

    This is the code I'm working on:

    Please Login or Register  to view this content.
    Any help is appreciated!

    Cheers,
    Adri

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Macro to delete cells containing a formula that results in ""

    do you want eliminate cells or rows ?
    If solved remember to mark Thread as solved

  3. #3
    Registered User
    Join Date
    08-17-2012
    Location
    home
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Macro to delete cells containing a formula that results in ""

    Hi Patel45,

    Ideally, I would like to check if the row has any data. If so, only the cell is deleted.
    Otherwise, if the row contains no data, it can be completely deleted.

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Macro to delete cells containing a formula that results in ""

    Hi, Adri,

    change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    Ciao,
    Holger

  5. #5
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Macro to delete cells containing a formula that results in ""

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    08-17-2012
    Location
    home
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Macro to delete cells containing a formula that results in ""

    Hi patel45,
    This won't delete the row if blank, is that right?

  7. #7
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Macro to delete cells containing a formula that results in ""

    Hi, Adri,

    could you please be kind enough to tell me the formula that results in ""? I expect a different way to be pratical as well.

    BTW: The changed line of code should read

    Please Login or Register  to view this content.
    And patel45īs code will only delete the cell, for the delete of the row you would need to change to
    Please Login or Register  to view this content.
    Cia,
    Holger
    Last edited by HaHoBe; 08-23-2012 at 01:37 AM. Reason: typos

  8. #8
    Registered User
    Join Date
    08-17-2012
    Location
    home
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Macro to delete cells containing a formula that results in ""

    Hi patel45,
    Your code
    Please Login or Register  to view this content.
    does work, but I need to run the macro 2 or 3 times, any ideas why? It doesn't delete all the cells when it first ran.

  9. #9
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Macro to delete cells containing a formula that results in ""

    Hi, Adri,

    this happens due to the fact that patelīs code starts at the top and after a deletion continues in the next row not condering that a ""-Cell may have been shifted up.

    The code you found wonīt show that because it starts at the bottom and works up. So in total:
    Please Login or Register  to view this content.
    And what do you really want? Cell deleted or EntireRow?

    Ciao,
    Holger

  10. #10
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Macro to delete cells containing a formula that results in ""

    Quote Originally Posted by adrianodl View Post
    does work, but I need to run the macro 2 or 3 times, any ideas why? It doesn't delete all the cells when it first ran.
    I don't find this problem on my file, can you attach a sample of your ?

  11. #11
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Macro to delete cells containing a formula that results in ""

    Hi, patel45,

    you read my post? Apparently not. Just double up the number of "" in your file/selection and - be surpised to find out.

    Ciao,
    Holger

  12. #12
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Macro to delete cells containing a formula that results in ""

    Yes, I did not see with attention, maybe this is solution
    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)

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