+ Reply to Thread
Results 1 to 6 of 6

Sub () exiting unexpectedly... any ideas why?

  1. #1
    Forum Contributor
    Join Date
    08-16-2010
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    132

    Sub () exiting unexpectedly... any ideas why?

    I didn't realize that SUB()s had size limits on them.

    A few days ago Excel informed me that the length of my main sub was too long, so I decided to split a section of my macro out into a new sub, then call it when I needed it.

    I am now having ALL sorts of problems, and I can't figure out why.

    In what used to be my only SUB(), I get to a place in the code where I call this new sub that I have moved the remainder of my code to. I've placed stops before and after the call for debugging purposes.

    Please Login or Register  to view this content.
    Once it hits this, it goes into this new sub and performs actions. However, it gets to a certain line, then just quits back to the main sub.

    Please Login or Register  to view this content.
    There is nothing wrong with this last line, but once it hits this, it goes back into the MAIN sub back to the stop directly AFTER teamsettings
    Please Login or Register  to view this content.
    and I can't figure out why! If I F8 through the code and bypass this line, a little bit later I get to the following line:
    Please Login or Register  to view this content.
    which is supposed to call up the IBM 3270 Terminal, which also worked perfectly before, and that juts kicks me out of the sub back to the line in the main sub where I called this from.

    Putting different pieces of code into different subs is somewhat new to me. Is there something I'm not doing correctly? I found that there were certain variables which I had declared in the first sub which were no longer working once I moved into teamsettings(), so I made those Public variables up at the top, (e.g.)

    Please Login or Register  to view this content.
    But apart from that that's the only change I've made. Can someone help me understand what I've done wrong to screw this up?

    Thanks!

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Sub () exiting unexpectedly... any ideas why?

    Can we see the main sub?

    PS Splitting up code is one way to deal with the size limit, but there are others. For example you could shorten the code.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    08-16-2010
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    132

    Re: Sub () exiting unexpectedly... any ideas why?

    what about the main sub do you want to see? Like.. the whole thing? I could possibly shorten the code, but that won't fix the problem in the long run. I still need to add more over time as the project grows.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Sub () exiting unexpectedly... any ideas why?

    Well I'd actually like to know how you are calling the other subs, how you are triggering/running the main sub etc.

    As for shortening the code, have you tried anything?

    Here's an example, this code,
    Please Login or Register  to view this content.
    can be shortened to this.
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    08-16-2010
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    132

    Re: Sub () exiting unexpectedly... any ideas why?

    Trying to paste the code and my comments, I'm up to about 60,000 characters. Way too long for a post. Is there another way I can send it to you?

  6. #6
    Forum Contributor
    Join Date
    08-16-2010
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    132

    Re: Sub () exiting unexpectedly... any ideas why?

    Test.xlsm

    Here's a copy of what I believe to be the key parts of the macro that are not functioning.

+ 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] Macro quites unexpectedly
    By CharterJP in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 11-23-2012, 07:39 PM
  2. Do-While loop continues unexpectedly
    By Motox in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-01-2012, 08:40 PM
  3. Solver crashes unexpectedly
    By prabodh1234 in forum Excel General
    Replies: 4
    Last Post: 07-06-2009, 12:11 PM
  4. [SOLVED] Help with formula that unexpectedly returns an answer
    By Geoff C in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 01:05 AM
  5. [SOLVED] Sub Exits Unexpectedly
    By Walker in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-25-2005, 06:06 PM

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