+ Reply to Thread
Results 1 to 3 of 3

Puzzle attached: Sub not executing every time. Plays up depending on what sheet is active

  1. #1
    Registered User
    Join Date
    10-27-2012
    Location
    Uk
    MS-Off Ver
    Excel 2010
    Posts
    98

    Question Puzzle attached: Sub not executing every time. Plays up depending on what sheet is active

    Hi All

    Hopefully someone clever can figure out what is going on in this workbook

    In each SLA sheet there are 2x form control buttons to add / delete sheets
    When any sheet with name beginning 'SLA...' is active, 'add new sheet' button does not fire on first click 80% of the time (same for the execute button in the VBA editor, it's hit or miss)

    However it works 100% of the time if run from any other sheet?! (any sheet where the name does not begin 'SLA...')
    It also works every time in the VBA editor if I use the F8 key to step though?

    So basically it doesn't work properly in the one place I need it to, on the SLA sheets >.<

    The idea behind the 'Add New Sheet' button is that it calls a macro called Listsheets() first.
    This lists all the sheets in the workbook that begin 'SLA... in Sheet5.CellsB37 onwards.

    Sheet5.CellB34 then displays what the next added sheet should be called

    At the end of Listsheets() macro NewSLASheet() is called, which adds a new copied sheet & names it per the value in Sheet5.CellB34

    As far as I can tell the problem seems to occur right from the start with Listsheets() not firing?

    I am lost on this one, so any advice would be greatly appreciated
    Many thanks in advance
    Vicky
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    12-14-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2007
    Posts
    439

    Re: Puzzle attached: Sub not executing every time. Plays up depending on what sheet is act

    The macro stops after line Sheet5.Range("B37:B100").ClearContents (Sub Listsheets)
    I think the worksheets named SLA... contain something with error formulas. So when Sheet5 change, the formulas recalculate, the error occurred and the macro stops.
    To solve this proplem, you should prevent the formulas recalculate by Application.Calculation command
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    10-27-2012
    Location
    Uk
    MS-Off Ver
    Excel 2010
    Posts
    98

    Re: Puzzle attached: Sub not executing every time. Plays up depending on what sheet is act

    Thank you so much! There's never a day I don't learn something new when I'm on this forum

+ 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. Scrolling left or right depending on position within active sheet
    By esbencito in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 07-31-2018, 03:02 AM
  2. [SOLVED] Calculating time/overtime/rates for employees - sheet attached
    By dawsonsoo in forum Excel General
    Replies: 4
    Last Post: 09-30-2014, 12:22 PM
  3. macro to send an email with an active excel sheet attached
    By megtoma in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-21-2014, 11:37 PM
  4. [SOLVED] Active sheet shifts back to original sheet when executing code
    By pcdog in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 10-22-2012, 11:07 AM
  5. [SOLVED] Can Chart display 2 year at a time in attached sheet
    By sumonrezadu in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 03-26-2012, 02:02 PM
  6. Using sumif to show win loss when 1 team plays 4 others
    By Laurence1965 in forum Excel Formulas & Functions
    Replies: 20
    Last Post: 09-22-2011, 02:07 PM
  7. Date/Time Macro Puzzle
    By Michael Link in forum Excel General
    Replies: 2
    Last Post: 03-15-2005, 11:06 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