+ Reply to Thread
Results 1 to 5 of 5

IF data on opened worksheet has blank data then cancel macro and move onto next part

  1. #1
    Forum Contributor
    Join Date
    09-03-2012
    Location
    Newcastle
    MS-Off Ver
    Excel 2010
    Posts
    132

    Exclamation IF data on opened worksheet has blank data then cancel macro and move onto next part

    Hi,

    So I'm using VB which transfers data from one worksheet to a master. Commonly at the start of the month the worksheet has no data, and the VB code gives me an error message.

    This is the code I am currently using:

    Please Login or Register  to view this content.

    So at the start of the month when there could be no data in the excels, when A5:N5 or A6:G6 is selected, then Range(Selection, Selection.End(xlDown)).Select is applied, there is no data so the VB brings back an error.

    I could remove Range(Selection, Selection.End(xlDown)).Select and replace it with a selected bottom row, but the amount of data could change at anytime.

    Any thoughts/help on this one?

    Cheers!
    Last edited by jonathan.haynes; 11-01-2013 at 06:22 AM.

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: IF data on opened worksheet has blank data then cancel macro and move onto next part

    Maybe:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    04-29-2013
    Location
    Ontario, Canada
    MS-Off Ver
    MS Office 2010
    Posts
    80

    Re: IF data on opened worksheet has blank data then cancel macro and move onto next part

    Use "On Error Resume Next" to bypass the error. BTW the script you posted is also missing "End Sub".

    Draconi

  4. #4
    Forum Contributor
    Join Date
    09-03-2012
    Location
    Newcastle
    MS-Off Ver
    Excel 2010
    Posts
    132

    Re: IF data on opened worksheet has blank data then cancel macro and move onto next part

    Thanks both, sorted

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: IF data on opened worksheet has blank data then cancel macro and move onto next part

    You're welcome. Glad to help out and thanks for the feedback.

+ 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. Need Macro to move data from one worksheet to another
    By sugarweasel in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-28-2013, 03:50 PM
  2. Move completed data from one worksheet to next blank row of another
    By Loisw in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-21-2013, 11:26 AM
  3. [SOLVED] Macro/VBA code to Copy data from primary worksheet to a worksheet opened by macro
    By MHamid in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-30-2013, 11:10 AM
  4. [SOLVED] Macro will not move copied data to next blank row?
    By DG370 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-15-2013, 10:54 AM
  5. Macro to move horizontal data to vertical - in new sheet--excluding blank cells
    By Jackdaddy0711 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-25-2012, 12:54 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