+ Reply to Thread
Results 1 to 5 of 5

Change a worksheet i goto error

  1. #1
    Forum Contributor
    Join Date
    03-29-2013
    Location
    lakewood, usa
    MS-Off Ver
    exce2013
    Posts
    112

    Change a worksheet i goto error

    I have the following loop in a Macro. I need to have the ON Error GoTo Label to Increase the ws by 1 and resume.
    Please Login or Register  to view this content.

  2. #2
    Registered User
    Join Date
    07-02-2013
    Location
    Cheshire
    MS-Off Ver
    Office Professional 2007
    Posts
    79

    Re: Change a worksheet i goto error

    Hi there. You could achieve this by having errorone just before the end of the for loop like this:
    Please Login or Register  to view this content.
    Last edited by maclearyj; 04-06-2020 at 03:49 AM.

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Change a worksheet i goto error

    This would test if the sheet name exists...

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  4. #4
    Forum Contributor
    Join Date
    03-29-2013
    Location
    lakewood, usa
    MS-Off Ver
    exce2013
    Posts
    112

    Re: Change a worksheet i goto error

    AlphaFrog, You nailed it! Ran some test and looks good. I struggled with his one for quite a while. Much better options than with On Error GoTo.
    The attached code allows me to List the Tabs that are Missing. Staying at home, no golf, so posting scores to a new project.
    Thanks again and stay safe and well.


    Please Login or Register  to view this content.
    Remember it is all Purple Smoke & Mirrors
    Last edited by wyowhite; 04-08-2020 at 11:59 AM.

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Change a worksheet i goto error

    You're welcome.

    Alternatively (for posterity), you could create a custom IsSheet function...

    Please Login or Register  to view this content.
    ...and call it with something like this.

    Please Login or Register  to view this content.
    Neither IsSheet or Evaluate("ISREF are ideas original to me.

    Please add CODE tags around your post #4 code.
    Last edited by AlphaFrog; 04-07-2020 at 06:12 PM.

+ 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] .Match with On Error: On Error Resume Next works. On Error GoTo only works once. Err.Clear
    By Doc.AElstein in forum Excel - New Users/Basics
    Replies: 28
    Last Post: 03-16-2015, 12:55 PM
  2. Need to add if error code to worksheet change event to stop a run-time error
    By KT99 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-18-2014, 03:10 PM
  3. [SOLVED] Error Occurs while running to On Error Goto Line3
    By moinsk21 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-01-2014, 02:37 PM
  4. On error goto
    By tostle in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-20-2010, 05:24 AM
  5. Run-time error '91' when 'On error goto' and cells.find
    By bjoern in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-09-2008, 07:27 PM
  6. On Error Goto (Global Error Handling)
    By mpeplow in forum Excel General
    Replies: 3
    Last Post: 04-10-2007, 11:33 PM
  7. [SOLVED] Error Handling - On Error GoTo doesn't trap error successfully
    By David in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-16-2006, 02:10 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