+ Reply to Thread
Results 1 to 8 of 8

VBA ignore blank cells

  1. #1
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    MS OFFICE 2016
    Posts
    24

    VBA ignore blank cells

    I want the run the code below, however in the range C6:AB83 I want to ignore blank cells. I'm guessing If cell <> "" Then run code would do the trick but I'm not sure where to insert. Could you help?


    Please Login or Register  to view this content.
    Last edited by Chris220; 07-15-2019 at 10:58 AM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA ignore blank cells

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,072

    Re: VBA ignore blank cells

    Try adding this line
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    MS OFFICE 2016
    Posts
    24

    Re: VBA ignore blank cells

    Perfect thanks, is there anyway I could also adjust the code to ignore merged cells. every time I click on merged cells an error appears called run-time 13.

  5. #5
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: VBA ignore blank cells

    Code can be adapted to deal with merged cells, but if you just want to skip those then either before or after the If Target = "" you can put:

    Please Login or Register  to view this content.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,072

    Re: VBA ignore blank cells

    Best way is to get rid of the merged cells, they should be avoided like the plague and will only give massive amounts of grief.

    If you have to keep them try
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    MS OFFICE 2016
    Posts
    24

    Re: VBA ignore blank cells

    Advice taken I'll get rid of merged cells

  8. #8
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,072

    Re: VBA ignore blank cells

    Glad to hear it, not only does VBA hate them, but they interfere with sorting, filtering & some formulae.
    If the cells are merged horizontally rather than vertically, you can get a similar visual affect using "Center across selection"
    https://www.atlaspm.com/toms-tutoria...merging-cells/

    Thanks for the Rep

+ 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. Replies: 2
    Last Post: 08-13-2018, 02:30 AM
  2. [SOLVED] how to count cells with values but ignore blank cells with formula and in a month?
    By Imran Magsi in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 02-17-2017, 03:58 AM
  3. [SOLVED] Ignore blank cells with formulas or ignore NA() in a formula
    By guiismiti in forum Excel Charting & Pivots
    Replies: 5
    Last Post: 03-24-2016, 02:13 PM
  4. Count number of cells in column per month, ignore blank cells
    By lamdl in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-13-2014, 08:50 PM
  5. Ignore blank cells and truly blank cells in named range?
    By hschillig in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-13-2014, 02:56 PM
  6. Replies: 5
    Last Post: 05-18-2013, 07:49 PM
  7. How can I make a macro ignore blank cells? - Blank Cells have formulas
    By mz1161 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-30-2013, 08:54 AM

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