+ Reply to Thread
Results 1 to 12 of 12

Looping Worksheet Macro - Skip a Sheet

  1. #1
    Registered User
    Join Date
    02-02-2015
    Location
    Brisbane
    MS-Off Ver
    2013
    Posts
    5

    Looping Worksheet Macro - Skip a Sheet

    Hi,
    I have this macro to cycle through all worksheets, retrieve data and paste into the "Test Lookup" sheet, but I want to skip one worksheet (called "Specs").

    Any thoughts on how? Thanks.
    Please Login or Register  to view this content.
    Last edited by Leith Ross; 02-02-2015 at 03:04 AM. Reason: Added Code Tags

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,937

    Re: Looping Worksheet Macro - Skip a Sheet

    Please Login or Register  to view this content.
    Ben Van Johnson

  3. #3
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Looping Worksheet Macro - Skip a Sheet

    Try this...

    Please Login or Register  to view this content.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  4. #4
    Registered User
    Join Date
    02-02-2015
    Location
    Brisbane
    MS-Off Ver
    2013
    Posts
    5

    Re: Looping Worksheet Macro - Skip a Sheet

    Quote Originally Posted by :) Sixthsense :) View Post
    Try this...

    Please Login or Register  to view this content.
    This worked (with "Next I" changed to "Next ws") - thanks to both!

  5. #5
    Registered User
    Join Date
    02-02-2015
    Location
    Brisbane
    MS-Off Ver
    2013
    Posts
    5

    Re: Looping Worksheet Macro - Skip a Sheet

    I just realised it's still going back to the "Spec" sheet at the end and copying and trying to paste data (but erroring as there's no data in those cells).

    Any ideas? Thanks.
    Last edited by tudley; 02-02-2015 at 09:15 PM.

  6. #6
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: Looping Worksheet Macro - Skip a Sheet

    Hi tudley,

    Here's how you could do it with your existing code:

    Please Login or Register  to view this content.
    HTH

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  7. #7
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Looping Worksheet Macro - Skip a Sheet

    Quote Originally Posted by tudley View Post
    I want to skip one worksheet (called "Specs")
    Please Login or Register  to view this content.
    Quote Originally Posted by tudley View Post
    I just realised it's still going back to the "Spec" sheet at the end and copying
    I given code based on your above statements.

    If your sheet name is spec not specS then correct it in the provided code.

  8. #8
    Registered User
    Join Date
    02-02-2015
    Location
    Brisbane
    MS-Off Ver
    2013
    Posts
    5

    Re: Looping Worksheet Macro - Skip a Sheet

    Quote Originally Posted by Trebor76 View Post
    Hi tudley,

    Here's how you could do it with your existing code:

    Please Login or Register  to view this content.
    HTH

    Robert
    Thanks, I still get a runtime error as it's copying all the blank data in the "Specs" worksheet.

    Quote Originally Posted by :) Sixthsense :) View Post
    I given code based on your above statements.

    If your sheet name is spec not specS then correct it in the provided code.
    Sorry, my typo, the worksheet name is "Specs".

    Also realised it was looking up data in blank sheets at the end. Deleting them and all good, except it runtime errors at "ws.select" when it gets to the end...
    Last edited by tudley; 02-03-2015 at 12:02 AM.

  9. #9
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Looping Worksheet Macro - Skip a Sheet

    Quote Originally Posted by tudley View Post
    except it runtime errors at "ws.select" when it gets to the end...
    I believe there is some availability of hidden worksheet(s)

    Try this revised code

    Please Login or Register  to view this content.

  10. #10
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: Looping Worksheet Macro - Skip a Sheet

    Thanks, I still get a runtime error as it's copying all the blank data in the "Specs" worksheet.
    I don't know what you mean as it should do nothing with that tab - it didn't for me when I created a workbook and called one of the tabs "Specs"

    Are you sure there's no trailing spaces in the tab name?

  11. #11
    Registered User
    Join Date
    02-02-2015
    Location
    Brisbane
    MS-Off Ver
    2013
    Posts
    5

    Re: Looping Worksheet Macro - Skip a Sheet

    @ Sixthsense - that worked - thankyou!

    @ Trebor76 - I thought that was strange too - just renamed the sheet again and it now skips it - working as well, so I have two options, thanks!

    Thanks all for you help.

  12. #12
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: Looping Worksheet Macro - Skip a Sheet

    @ Trebor76 - I thought that was strange too - just renamed the sheet again and it now skips it - working as well, so I have two options, thanks!
    There must have a space (or spaces) either at the start and/or end of the tab name.

    If you could mark the thread as solved it would be appreciated.

    Regards,

    Robert

+ 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] can't get macro to skip worksheet if row 2 is blank...
    By fabrecass in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-28-2012, 05:10 AM
  2. [SOLVED] Multiiple Worksheet Loop Macro only Looping on 1 sheet
    By lscarstens in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-20-2012, 02:44 PM
  3. [SOLVED] Event macro to skip worksheet
    By nickmax1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-31-2012, 11:42 AM
  4. Replies: 1
    Last Post: 08-18-2012, 06:59 PM
  5. macro to skip delete sheet question
    By excellentexcel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-13-2009, 08:40 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