+ Reply to Thread
Results 1 to 4 of 4

Macro only runs when stepping through it

  1. #1
    Registered User
    Join Date
    08-16-2016
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    88

    Macro only runs when stepping through it

    Hi guys,

    I'm quite new to VBA and I've been having a go at creating a macro which filters a sheet and copies the results to another sheet, whenever a user changes a particular cell. Basically, I have a drop down in cell B2 on a sheet called "CyBreakdown". Whenever the user selects from the drop down, I want the sheet "ACC" to be filtered and then the results are placed at cell A17 in the "CyBreakdown" sheet.

    The code works fine when I step through it manually, however when I run the macro in full, it doesn't do anything. I'm not sure where I'm going wrong.

    Here is the code I want to run:

    Please Login or Register  to view this content.
    And this is the code I have in the worksheet (CyBreakdown) when the dropdown in B2 is changed:

    Please Login or Register  to view this content.

    I don't know if it's something to do with the jumping between the code in the worksheet, and the code in a module?
    Since I'm pasting data back into the "CyBreakdown" sheet, the macro jumps back to the worksheet code because there has been a change...?

    Any input or advice would be great as I've been trying to do this myself and can't really figure out what to do, or if there is a much smarter way to do this!
    Thanks

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Macro only runs when stepping through it

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  3. #3
    Registered User
    Join Date
    08-16-2016
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    88

    Re: Macro only runs when stepping through it

    Wow, that was very simple!! Can you explain why making it an absolute reference makes the difference?
    Thanks

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Macro only runs when stepping through it

    Because the result of Target.Address is also displayed as absolute reference.

    Please Login or Register  to view this content.

+ 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. Code works fine when stepping through code but Excel freezes if I run it without stepping
    By OldManExcellor in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-19-2016, 10:39 AM
  2. VBA runs slow locally, runs fine when connected remotely
    By jbzy324 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-01-2015, 10:05 PM
  3. Replies: 4
    Last Post: 06-25-2014, 03:22 PM
  4. Stepping through a Macro that acceots parameters
    By slash_gnr3k in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-09-2013, 07:25 AM
  5. Replies: 0
    Last Post: 08-16-2012, 01:32 PM
  6. OpenText function in macro hangs unless stepping through code in debug
    By Part-Time Coder in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-06-2009, 05:32 PM
  7. [SOLVED] Macro Stepping
    By George in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-23-2006, 04:35 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