+ Reply to Thread
Results 1 to 6 of 6

User Defined Function Loop error

  1. #1
    Registered User
    Join Date
    04-13-2020
    Location
    London
    MS-Off Ver
    2013
    Posts
    5

    User Defined Function Loop error

    Hello,
    hope any of you could help me. I'm a beginner.

    I have a UDF + sub to generate some info. It works just fine at one run only - However, I need to execute this script for like 1.000 times in a row.

    Problem 1:
    --> If I create any kind of loop in this Sub, all information generated by my SUB will be the same - I need a unique value for each run.
    I already tried "function Volatile" - didn't work.
    It works if I run my module by clicking on a macro button several times, for example. But as I stated, I'd need this automated, as more than 1.000 runs will be needed.


    Problem 2:
    --> Tried to do the loop out of another Sub, however it gets "out of stack space 28" errors after 50 cycles (I already tried "EnableEvents false", didn't work)


    Is there any way I can create a loop after my UDF, then at the end, GOTO to function at the beginning and start all over, till my desired loop count?

    Thanks in advance for any kind input.
    Last edited by llxxzz; 02-15-2021 at 02:28 PM.

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

    Re: User Defined Function Loop error

    Can you post the code for the UDF (and sub) and explain further what's it's supposed to do?
    If posting code please use code tags, see here.

  3. #3
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    1,703

    Re: User Defined Function Loop error

    There are too many options to answer this question in general. We need specific examples. Please follow instructions in yellow banner above and we’ll see how to help.

  4. #4
    Registered User
    Join Date
    04-13-2020
    Location
    London
    MS-Off Ver
    2013
    Posts
    5

    Re: User Defined Function Loop error

    Thanks for such a quick response.

    The UDF randomizes a sequence of numbers.
    Then the SUB plays the UDF, stores the result in a couple of cells.
    Then I'd need to repeat this process many times.


    -------------------------- UDF ---------------------------
    Please Login or Register  to view this content.
    -----------------------------------------------------------
    -----------------------------------------------------------
    -----------------------------------------------------------
    -----------------------------------------------------------
    Please Login or Register  to view this content.
    Last edited by llxxzz; 02-16-2021 at 02:02 PM.

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

    Re: User Defined Function Loop error

    Code Tags Added
    Your post does not comply with Rule 2 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found at http://www.excelforum.com/forum-rule...rum-rules.html



    (I have added them for you today. Please take a few minutes to read all Forum Rules and comply in the future.)

  6. #6
    Registered User
    Join Date
    04-13-2020
    Location
    London
    MS-Off Ver
    2013
    Posts
    5

    Re: User Defined Function Loop error

    Apologies for I missed that.
    I have just updated it

+ 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. #NAME? error when using user defined function
    By alicebrewer in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-02-2013, 08:58 AM
  2. #NAME? error for user-defined vba function
    By psychopsanka in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-30-2009, 03:01 PM
  3. [SOLVED] #Name? Error in User Defined VB Function
    By George Nicholson in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 09-06-2005, 05:05 PM
  4. #Name? Error in User Defined VB Function
    By idgity in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 04:05 PM
  5. [SOLVED] #Name? Error in User Defined VB Function
    By idgity in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 PM
  6. #Name? Error in User Defined VB Function
    By George Nicholson in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-06-2005, 08:05 AM
  7. #Name? Error in User Defined VB Function
    By idgity in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 06:05 AM
  8. [SOLVED] #Name? Error in User Defined VB Function
    By idgity in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 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