+ Reply to Thread
Results 1 to 7 of 7

Unexpected Macro Run

  1. #1
    Registered User
    Join Date
    10-09-2013
    Location
    Salt Lake City
    MS-Off Ver
    Excel 2013
    Posts
    20

    Unexpected Macro Run

    Hello,

    I am running into a scenario where I don't intend the macro to run and i'm not sure how to make it stop.

    The macro is only supposed to run if columns 5 and 6 are filled however, for some reason this macro is running whenever I make a change to another cell. I think it has to do with this line of code:
    Please Login or Register  to view this content.
    . However, I am having a hard time figuring out how to fix it. Please help! Thank you Excel Gurus!!!

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: Unexpected Macro Run

    Put Stop as the first line of code in the event handler. Then make a change in the worksheet and use F8 to step through the code. Check the contents of cells and variables to see what is happening.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    10-09-2013
    Location
    Salt Lake City
    MS-Off Ver
    Excel 2013
    Posts
    20

    Re: Unexpected Macro Run

    I put stop in like this

    Please Login or Register  to view this content.
    [/CODE]

    and I pressed F8 to step through the code but I couldn't figure out what the problem was. Any suggestions?

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: Unexpected Macro Run

    And the password for the VBA project is … ?

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: Unexpected Macro Run

    Forget it … I guessed from the sheet password

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: Unexpected Macro Run

    Try this:

    Please Login or Register  to view this content.

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: Unexpected Macro Run

    Notes:

    1. You have a loop to UnProtect ALL the sheets at the beginning
    2. You have a loop to Protect ALL the sheets BUT it is inside the main IF block so it might not get executed
    3. By deleting a row within the Worksheet Change Event handler, you are making a change
    4. You need to disable and re-enable event handling around the changes you make within the event handler

+ 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] call various macro giving unexpected results , need to be run one by one
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-13-2017, 08:51 AM
  2. Vba Macro for advanced filter is giving unexpected results
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-22-2016, 02:09 PM
  3. Unexpected results in sorting macro
    By kcorless in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-05-2015, 01:43 PM
  4. Unexpected copy to next sheet in a macro
    By monkeykg in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-23-2014, 06:14 AM
  5. Macro for unexpected scenario
    By aniletc37 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-23-2014, 02:45 AM
  6. Unexpected crash after macro execution
    By szabi7 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-05-2012, 06:05 AM
  7. Unexpected run time error in Macro
    By Athilla in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-22-2009, 12:31 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