+ Reply to Thread
Results 1 to 6 of 6

Tell macro to skip blank cells in a range and only select those with data?

  1. #1
    Registered User
    Join Date
    01-31-2015
    Location
    London
    MS-Off Ver
    Excel 2019
    Posts
    89

    Tell macro to skip blank cells in a range and only select those with data?

    I have a very simple macro that is copying data from a range of cells and the macro is called from a button on a different worksheet to the one from on where the macro runs.
    I need a way of telling the macro to look at the cells in the specified range and only copy any data from formulas in the cells have that returned data but skip the cells with formulas that do not return any results (so when you are looking at the worksheet the cell looks empty even though it is not). The data in cells within the range may change depending on what a user (me) may enter before running the macro.

    This is the macro
    Please Login or Register  to view this content.

    Here is an example of how the range it is copying can look like
    Cell B1 = Red
    Cell B2 = Yellow

    Cell B4 = Green


    Cell B7 = Gray

    I need the macro to ignore the blank cells (the ones where the formulas do not return a result) so the macro results are:
    Cell B1 = Red
    Cell B2 = Yellow
    Cell B4 = Green
    Cell B7 = Gray

    This is beyond my knowledge so can anyone kindly help?

    Thanks in advance

  2. #2
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Tell macro to skip blank cells in a range and only select those with data?

    Maybe change your line to
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    01-31-2015
    Location
    London
    MS-Off Ver
    Excel 2019
    Posts
    89

    Re: Tell macro to skip blank cells in a range and only select those with data?

    Quote Originally Posted by JieJenn View Post
    Maybe change your line to
    Please Login or Register  to view this content.
    Hi JieJenn

    When I changed my line to what you suggest I get the following error:
    run-time error '1004': no cells were found

  4. #4
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Tell macro to skip blank cells in a range and only select those with data?

    Maybe
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-31-2015
    Location
    London
    MS-Off Ver
    Excel 2019
    Posts
    89

    Re: Tell macro to skip blank cells in a range and only select those with data?

    Quote Originally Posted by JieJenn View Post
    Maybe
    Please Login or Register  to view this content.
    Hi

    Thanks for the suggestion which I have just tried but all that happens now is the macro copies the words "On Error Resume Next" to the clipboard...

  6. #6
    Valued Forum Contributor
    Join Date
    06-21-2013
    Location
    Bangladesh
    MS-Off Ver
    Excel 2000, Excel XP, Excel 2002, Excel 2007, Excel 2010, Excel 2013
    Posts
    975

    Re: Tell macro to skip blank cells in a range and only select those with data?

    You are must doing something wrong. It would be better if you can upload a sample.

+ 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. [SOLVED] Adapting to following formula to skip blank cells in range
    By Jamidd1 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-20-2016, 04:26 PM
  2. [SOLVED] Go to right thru a range and skip all blank cells, return value of first non-blank in rang
    By mysticmoron109 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-16-2015, 03:47 PM
  3. Replies: 1
    Last Post: 10-16-2014, 08:00 PM
  4. Looking to create a macro that will skip blank cells in a column, find data cells
    By crayzwalz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-30-2013, 09:01 AM
  5. Select latest of 3 dates and skip blank cells
    By Skully in forum Excel General
    Replies: 16
    Last Post: 06-08-2011, 04:07 AM
  6. [SOLVED] Skip blank cells on transpose in a macro
    By Melanie O in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-22-2005, 10:05 AM
  7. [SOLVED] How do I skip blank cells when copying over a range of cells?
    By tawells in forum Excel General
    Replies: 2
    Last Post: 06-08-2005, 11:05 AM

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