+ Reply to Thread
Results 1 to 4 of 4

Skip a step in the Macro if a range has no data

  1. #1
    Registered User
    Join Date
    07-29-2013
    Location
    Frisco, TX
    MS-Off Ver
    Excel 2007
    Posts
    5

    Skip a step in the Macro if a range has no data

    Good afternoon,

    This is my first post here, but I have relied upon this forum for solutions to several other problems. So, gratitude is due for your indirect help on prior issues. Now hopefully you can help me directly with my current issue.

    I have a spreasheet and macro which takes bulk data, filters it and pastes it into different tabs based on category, and then subtotals that data before copying and pasting all of the subtotals onto another sheet. The problem I am having is that occasionally there is no data within a certain category, so the correponding sheet will be blank (except for headers). When the macro runs, I get a "run-time error '1004'" when it attempts to sub-total the data on the blank sheet. Is there a way to skip this step of the macro if there is no data within a certain sheet/range?

    If it helps, here is the portion of VBA language where it hangs-up:


    Please Login or Register  to view this content.
    Last edited by Leith Ross; 07-31-2013 at 02:41 PM. Reason: Added Code tags

  2. #2
    Forum Contributor codeslizer's Avatar
    Join Date
    05-28-2013
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003 - 2010
    Posts
    245

    Re: Skip a step in the Macro if a range has no data

    First of all, A very warm welcome to the Forum, buddy!

    And regarding your request.. you could try putting a check like the following. I use COUNTA() of WorksheetFunction to generally check the validation of a range.

    Please Login or Register  to view this content.
    cOdEsLiZeR - Back after a long break.. Let's sLiZe some more cOdEs!!

  3. #3
    Registered User
    Join Date
    07-29-2013
    Location
    Frisco, TX
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Skip a step in the Macro if a range has no data

    That doesn't do the trick. Could it be because there is a header?


    ps. Thanks for the warm welcome! I appreciate your help on this.
    Last edited by 1-Ton; 08-01-2013 at 12:23 PM.

  4. #4
    Registered User
    Join Date
    07-29-2013
    Location
    Frisco, TX
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Skip a step in the Macro if a range has no data

    I still get the same error code with this. I'm not sure, but maybe because there is a header? Incidentally, I found a solution from another thread that is working. But, I'm not sure if it is the best. Let me know what you think:
    On Error Resume Next
    Selection.Subtotal GroupBy:=1, Function:=xlCount, TotalList:=Array(1), _
    Replace:=True, PageBreaks:=False, SummaryBelowData:=False
    On Error GoTo 0

+ 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. Using VBA To Skip Step If There is Nothing In Cell?
    By alulla in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-26-2013, 08:53 AM
  2. [SOLVED] preventing simple zoom macro from running step by step
    By reece1984 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-11-2012, 06:13 AM
  3. Help with Macro, need it to skip a step if that step isn't needed
    By CDNcameron in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-23-2012, 02:34 PM
  4. run macro step by step. excel 2003
    By PBM in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-19-2005, 10:19 AM
  5. [SOLVED] I need step by step instructions to create a macro for 10 imbedde.
    By diana in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-30-2005, 10:06 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