+ Reply to Thread
Results 1 to 4 of 4

Setting focus on workbook when code is Running

  1. #1
    Forum Contributor
    Join Date
    11-29-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    104

    Setting focus on workbook when code is Running

    Full disclosure, I posted this code here earlier today, but I received an answer that resolved my issue.
    In this question, I have an odd issue. If I step through the code, it works as expected, but if I run the whole script, it does not produce the desired result. And I strongly believe it is because of the way I am referring to workbooks.

    I have blocked off the part of the code that I need help with. And by help I need:
    1. (If thee is one) A more efficient way of accomplishing what I am trying to do with the code. Mainly loop through a range and convert formulas to values (which works fine) and delete hidden rows. I'm thinking this can be done with one loop, but I have not been able to figure it out.
    2. Fix what is causing the issue of the code behaving unexpectedly.

    Everything within the "'####################" is supposed to be done in the newly created workbook. However after the file saves and closes and I reopen, it seems that some parts of the code did not run? I am honestly at a loss for what I am doing wrong and I am looking for someone with a bit more knowledge to guide me in the right direction.


    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by jrean042; 07-02-2020 at 07:44 AM.

  2. #2
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Setting focus on workbook when code is Running

    Using With statements might help...
    https://docs.microsoft.com/en-us/dot...with-statement
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    11-29-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    104

    Re: Setting focus on workbook when code is Running

    This is excellent!
    Thank you very much for your time.
    It was the syntax of naming the activeworkbook and then explicitly defining it that I was having trouble with.
    I learned something new here. Thank you again

  4. #4
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Setting focus on workbook when code is Running

    Glad it helps!

+ 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. Macro only works step-by-step
    By smw10c in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-31-2020, 10:41 AM
  2. [SOLVED] Paste Visible Cells Only - works only if step through code manually
    By dflak in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-10-2019, 10:36 AM
  3. Macro errors when running, but works when done step by step
    By taylorsm in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-02-2018, 03:54 PM
  4. VBA Code works by step by step, doesn't work by running
    By lucasar in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-24-2016, 06:33 AM
  5. VBA Code works with step (f8) not run <ctrl>f8
    By rmacia in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-05-2013, 02:26 PM
  6. My VBA code works in the step though mode but not at full speed
    By Kelly in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-15-2005, 10:06 PM

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