+ Reply to Thread
Results 1 to 5 of 5

split the code while argument is not affected

  1. #1
    Registered User
    Join Date
    02-23-2013
    Location
    earth
    MS-Off Ver
    Excel 2010
    Posts
    21

    split the code while argument is not affected

    try to develop user-define function named abc(),due to the error "procedure too large" , i was forced to split the code and now the function return 0 instead expected result "3"

    Please Login or Register  to view this content.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: split the code while argument is not affected

    Your functions are not connected to each other, nor are they currently open to feeding parameters one to another.

    Please Login or Register  to view this content.
    In this function you are setting abc = to p1 +p2, but in the code above that in the function there is no code to give values to P1 or P2. So you are adding 0 + 0. You'll need to use INDEX100 to resolve p1 & P2 first.

    I've merged that into one function that would appear to do the correct thing:
    Please Login or Register  to view this content.
    I'm assuming the lines in red will actually be removed and you will use the function to feed in the 4 parameters via cell reference.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    02-23-2013
    Location
    earth
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: split the code while argument is not affected

    Quote Originally Posted by JBeaucaire View Post
    Your functions are not connected to each other, nor are they currently open to feeding parameters one to another.
    that what i am looking for, how to make the code connected to each other or feeding parameters to another???

    the code you merged for me is not what i need,because i had lots of calculation in my code under one function which causing error"procedure too large" and now i forced to split the code.

    yeah,the line in red will remove and will feed the 4 parameters via cell reference

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: split the code while argument is not affected

    How long was the procedure too large?

    When creating a function, the parameters in the () denote the values that will be used in the function. When calling that function from another function, be sure to insert those parameters into the call, the same way you fill out a formula's parameters as you enter it into a cell.


    In your original code above, the INDEX100 could be used to bring back a single result. But it looks like you need results to resolve the values of P1 and P2. I would suggest creating functions for those.

    Here's a very simple example of what I mean. Here I've created a GetP1 and a GetP2 function, within those functions you can do whatever routines you need, but the end result is a single value fed back as the result of GetP1. In the main macro, that result is stored into a variable and used as needed.

    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 05-14-2013 at 01:09 PM.

  5. #5
    Registered User
    Join Date
    02-23-2013
    Location
    earth
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: split the code while argument is not affected

    my code is over 64 kb in a single function without code splitting,that why the error pop out.

    that what i am looking for,thank you very much.
    Last edited by ck_123; 05-15-2013 at 09:56 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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