+ Reply to Thread
Results 1 to 6 of 6

Code runs but with no effect

  1. #1
    Registered User
    Join Date
    06-18-2013
    Location
    Copenhagen
    MS-Off Ver
    Excel 2010
    Posts
    15

    Code runs but with no effect

    Hello. I've made this code to restructure an existing excel report. If I go to the VBA editor and just press F8 all the way the code runs perfectly.
    If I use ALT+F8 and click "run" then by some reason the code skips the same part of the code every time.

    Please Login or Register  to view this content.
    The code highlighted is the code that is skipped when I click "run" or use a button to run the code.

    I've no clue why it is like that. I'm using excel 2010. The code actually worked w/o problems but suddenly when I worked with a different part of the code, those 4 lines suddenly stopped working

    I even made a new macro just containing this code as well as another part of the code that fails to run at occasions. THIS code ALSO doesn't work when using "run" or when I run it using a button, but works if I press F8

    Please Login or Register  to view this content.
    Any feedback is appreciated also if there's suggestions to my code that could be optimized

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Code runs but with no effect

    You are missing some dotes with with end with

    Please Login or Register  to view this content.
    Last edited by AB33; 08-14-2013 at 09:07 AM.

  3. #3
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: Code runs but with no effect

    Looks like AB33 has provided the solution
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  4. #4
    Registered User
    Join Date
    06-18-2013
    Location
    Copenhagen
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Code runs but with no effect

    Thank you for your response. I'm not sure I understand it though. As far as I can see, every 'with' statement is closed with an 'end with' statement. Are you suggesting that I shouldn't use 'with'/'end with' statement nested inside a previous 'with'/'end with' statement?

    Then I'm wondering why it works when using Run Sub/Userform inside the VBA editor?

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Code runs but with no effect

    Then I'm wondering why it works when using Run Sub/Userform inside the VBA editor?

    It is probably your cursor might be on the active sheet.

  6. #6
    Registered User
    Join Date
    06-18-2013
    Location
    Copenhagen
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Code runs but with no effect

    My mistake: It didn't work when using Run Sub/Userform. But it worked when using the 'step into F8' function.

    Just moved all the nested 'with'/'end with' statements outside and now it works even when using "Run sub/Userform" - Stupid VBA Can't even handle nested with statements! properly

    Thank you

+ 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. make my code effect on more then 1 sheet
    By moshelog in forum Excel General
    Replies: 1
    Last Post: 05-01-2012, 02:47 AM
  2. Code runs when tab activated?
    By StephanieD in forum Excel General
    Replies: 3
    Last Post: 01-09-2012, 01:49 PM
  3. Code help appreciated:Code runs fine
    By peter.thompson in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-22-2006, 10:03 PM
  4. How open statements effect code
    By cereldine in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-21-2006, 06:40 AM
  5. Code only runs once
    By Kent in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-24-2005, 11:50 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