“Out of Memory” VBA error after trying to register descriptions of UDFs












1















I have created a series of VBA mathematical functions in an Excel spreadsheet (i.e. minimisation algorithms). These functions have been tested and they seem to be working properly. I want to add a description of these function and their arguments therefore, based on this question on the topic, I tried to code some subroutines that would achieve that:





  • First, I created a subroutine to actually encapsulate the descriptions:



    Sub RegisterUDF()

    myFunctionOneDescription = "Long FunctionOne description" & vbLf _
    & "myFunctionOne(<...>, ..., <...>)"
    myFunctionOneArguments = Array("FunctionOne argument 1 description", _
    "FunctionOne argument 2 description", _
    "FunctionOne argument 3 description", _
    "FunctionOne argument 4 description", _
    "[Optional] FunctionOne argument 5 description")

    myFunctionTwoDescription = "Long FunctionTwo description" & vbLf _
    & "myFunctionTwo(<...>, ..., <...>)"
    myFunctionTwoArguments = Array("FunctionTwo argument 1 description", _
    "FunctionTwo argument 2 description", _
    "FunctionTwo argument 3 description", _
    "FunctionTwo argument 4 description", _
    "[Optional] FunctionTwo argument 5 description")

    myFunctionThreeDescription = "Long FunctionThree description" & vbLf _
    & "myFunctionThree(<...>, ..., <...>)"
    myFunctionThreeArguments = Array("FunctionThree argument 1 description", _
    "FunctionThree argument 2 description", _
    "FunctionThree argument 3 description", _
    "FunctionThree argument 4 description", _
    "[Optional] FunctionThree argument 5 description")

    Application.MacroOptions Macro:="myFunctionOne", Description:=myFunctionOneDescription, ArgumentDescriptions:=myFunctionOneArguments, Category:=9
    Application.MacroOptions Macro:="myFunctionTwo", Description:=myFunctionTwoDescription, ArgumentDescriptions:=myFunctionTwoArguments, Category:=9
    Application.MacroOptions Macro:="myFunctionThree", Description:=myFunctionThreeDescription, ArgumentDescriptions:=myFunctionThreeArguments, Category:=9

    End Sub



  • Then, I create the following subroutine in the ThisWorkbook object:



    Private Sub Workbook_Open()
    Call RegisterUDF
    End Sub


    so that the descriptions are automatically loaded when I open the workbook.




When creating these two subroutines and assessing the look of the function descriptions in the Function UI (namely the one that pops up when you press Ctrl+Shift+A or fx), I started closing and reopening the workbook given descriptions are updated only when Workbook_Open() is executed. Then, at some point I started getting an Out of Memory error immediately after opening the workbook; the error seemed to originate from the third function description above:





I started getting rid of these two subroutines but now I still see the Out of Memory error when I refresh my workbook (whose tabs are populated with instances of my user-defined functions); each time, the Out of Memory error seems to originate in one of my UDFs but not always the same. In addition, when I try to cancel the debugging by resetting VBA, I get a new Out of Memory error immediately after, before having refreshed the workbook or performed any additional action, thus I end trapped in a "loop" of Out of Memory errors and I am forced to close Excel from the Task Manager (1). This had never happened before I tried to code the functions' descriptions.



Can anybody help me in understanding what might be going on? I suspect this is related to the utilisation of Application.MacroOptions but I am unsure. Any help is greatly appreciated.



(1) I suspect this is actually explained by the fact that, when I refresh the workbook or a tab, multiple instances of my UDFs will try to reevaluate hence each Out of Memory error corresponds to one instance of my UDFs.



[EDIT #1] I observe very strange behaviour. For example, on a tab with preexisting instances of my UDFs in some cells, I have tried to evaluate one of my functions in a new cell after having commented out the 2 subroutines described above. When writing down the function in the cell and pressing enter, I got the Out of Memory error originating from the code of that UDF. Then, I deleted from the VBA code the commented subroutines and when pressing enter the function evaluated correctly! However, when refreshing that tab, I then got the same memory error but this time coming from another UDF.










share|improve this question





























    1















    I have created a series of VBA mathematical functions in an Excel spreadsheet (i.e. minimisation algorithms). These functions have been tested and they seem to be working properly. I want to add a description of these function and their arguments therefore, based on this question on the topic, I tried to code some subroutines that would achieve that:





    • First, I created a subroutine to actually encapsulate the descriptions:



      Sub RegisterUDF()

      myFunctionOneDescription = "Long FunctionOne description" & vbLf _
      & "myFunctionOne(<...>, ..., <...>)"
      myFunctionOneArguments = Array("FunctionOne argument 1 description", _
      "FunctionOne argument 2 description", _
      "FunctionOne argument 3 description", _
      "FunctionOne argument 4 description", _
      "[Optional] FunctionOne argument 5 description")

      myFunctionTwoDescription = "Long FunctionTwo description" & vbLf _
      & "myFunctionTwo(<...>, ..., <...>)"
      myFunctionTwoArguments = Array("FunctionTwo argument 1 description", _
      "FunctionTwo argument 2 description", _
      "FunctionTwo argument 3 description", _
      "FunctionTwo argument 4 description", _
      "[Optional] FunctionTwo argument 5 description")

      myFunctionThreeDescription = "Long FunctionThree description" & vbLf _
      & "myFunctionThree(<...>, ..., <...>)"
      myFunctionThreeArguments = Array("FunctionThree argument 1 description", _
      "FunctionThree argument 2 description", _
      "FunctionThree argument 3 description", _
      "FunctionThree argument 4 description", _
      "[Optional] FunctionThree argument 5 description")

      Application.MacroOptions Macro:="myFunctionOne", Description:=myFunctionOneDescription, ArgumentDescriptions:=myFunctionOneArguments, Category:=9
      Application.MacroOptions Macro:="myFunctionTwo", Description:=myFunctionTwoDescription, ArgumentDescriptions:=myFunctionTwoArguments, Category:=9
      Application.MacroOptions Macro:="myFunctionThree", Description:=myFunctionThreeDescription, ArgumentDescriptions:=myFunctionThreeArguments, Category:=9

      End Sub



    • Then, I create the following subroutine in the ThisWorkbook object:



      Private Sub Workbook_Open()
      Call RegisterUDF
      End Sub


      so that the descriptions are automatically loaded when I open the workbook.




    When creating these two subroutines and assessing the look of the function descriptions in the Function UI (namely the one that pops up when you press Ctrl+Shift+A or fx), I started closing and reopening the workbook given descriptions are updated only when Workbook_Open() is executed. Then, at some point I started getting an Out of Memory error immediately after opening the workbook; the error seemed to originate from the third function description above:





    I started getting rid of these two subroutines but now I still see the Out of Memory error when I refresh my workbook (whose tabs are populated with instances of my user-defined functions); each time, the Out of Memory error seems to originate in one of my UDFs but not always the same. In addition, when I try to cancel the debugging by resetting VBA, I get a new Out of Memory error immediately after, before having refreshed the workbook or performed any additional action, thus I end trapped in a "loop" of Out of Memory errors and I am forced to close Excel from the Task Manager (1). This had never happened before I tried to code the functions' descriptions.



    Can anybody help me in understanding what might be going on? I suspect this is related to the utilisation of Application.MacroOptions but I am unsure. Any help is greatly appreciated.



    (1) I suspect this is actually explained by the fact that, when I refresh the workbook or a tab, multiple instances of my UDFs will try to reevaluate hence each Out of Memory error corresponds to one instance of my UDFs.



    [EDIT #1] I observe very strange behaviour. For example, on a tab with preexisting instances of my UDFs in some cells, I have tried to evaluate one of my functions in a new cell after having commented out the 2 subroutines described above. When writing down the function in the cell and pressing enter, I got the Out of Memory error originating from the code of that UDF. Then, I deleted from the VBA code the commented subroutines and when pressing enter the function evaluated correctly! However, when refreshing that tab, I then got the same memory error but this time coming from another UDF.










    share|improve this question



























      1












      1








      1








      I have created a series of VBA mathematical functions in an Excel spreadsheet (i.e. minimisation algorithms). These functions have been tested and they seem to be working properly. I want to add a description of these function and their arguments therefore, based on this question on the topic, I tried to code some subroutines that would achieve that:





      • First, I created a subroutine to actually encapsulate the descriptions:



        Sub RegisterUDF()

        myFunctionOneDescription = "Long FunctionOne description" & vbLf _
        & "myFunctionOne(<...>, ..., <...>)"
        myFunctionOneArguments = Array("FunctionOne argument 1 description", _
        "FunctionOne argument 2 description", _
        "FunctionOne argument 3 description", _
        "FunctionOne argument 4 description", _
        "[Optional] FunctionOne argument 5 description")

        myFunctionTwoDescription = "Long FunctionTwo description" & vbLf _
        & "myFunctionTwo(<...>, ..., <...>)"
        myFunctionTwoArguments = Array("FunctionTwo argument 1 description", _
        "FunctionTwo argument 2 description", _
        "FunctionTwo argument 3 description", _
        "FunctionTwo argument 4 description", _
        "[Optional] FunctionTwo argument 5 description")

        myFunctionThreeDescription = "Long FunctionThree description" & vbLf _
        & "myFunctionThree(<...>, ..., <...>)"
        myFunctionThreeArguments = Array("FunctionThree argument 1 description", _
        "FunctionThree argument 2 description", _
        "FunctionThree argument 3 description", _
        "FunctionThree argument 4 description", _
        "[Optional] FunctionThree argument 5 description")

        Application.MacroOptions Macro:="myFunctionOne", Description:=myFunctionOneDescription, ArgumentDescriptions:=myFunctionOneArguments, Category:=9
        Application.MacroOptions Macro:="myFunctionTwo", Description:=myFunctionTwoDescription, ArgumentDescriptions:=myFunctionTwoArguments, Category:=9
        Application.MacroOptions Macro:="myFunctionThree", Description:=myFunctionThreeDescription, ArgumentDescriptions:=myFunctionThreeArguments, Category:=9

        End Sub



      • Then, I create the following subroutine in the ThisWorkbook object:



        Private Sub Workbook_Open()
        Call RegisterUDF
        End Sub


        so that the descriptions are automatically loaded when I open the workbook.




      When creating these two subroutines and assessing the look of the function descriptions in the Function UI (namely the one that pops up when you press Ctrl+Shift+A or fx), I started closing and reopening the workbook given descriptions are updated only when Workbook_Open() is executed. Then, at some point I started getting an Out of Memory error immediately after opening the workbook; the error seemed to originate from the third function description above:





      I started getting rid of these two subroutines but now I still see the Out of Memory error when I refresh my workbook (whose tabs are populated with instances of my user-defined functions); each time, the Out of Memory error seems to originate in one of my UDFs but not always the same. In addition, when I try to cancel the debugging by resetting VBA, I get a new Out of Memory error immediately after, before having refreshed the workbook or performed any additional action, thus I end trapped in a "loop" of Out of Memory errors and I am forced to close Excel from the Task Manager (1). This had never happened before I tried to code the functions' descriptions.



      Can anybody help me in understanding what might be going on? I suspect this is related to the utilisation of Application.MacroOptions but I am unsure. Any help is greatly appreciated.



      (1) I suspect this is actually explained by the fact that, when I refresh the workbook or a tab, multiple instances of my UDFs will try to reevaluate hence each Out of Memory error corresponds to one instance of my UDFs.



      [EDIT #1] I observe very strange behaviour. For example, on a tab with preexisting instances of my UDFs in some cells, I have tried to evaluate one of my functions in a new cell after having commented out the 2 subroutines described above. When writing down the function in the cell and pressing enter, I got the Out of Memory error originating from the code of that UDF. Then, I deleted from the VBA code the commented subroutines and when pressing enter the function evaluated correctly! However, when refreshing that tab, I then got the same memory error but this time coming from another UDF.










      share|improve this question
















      I have created a series of VBA mathematical functions in an Excel spreadsheet (i.e. minimisation algorithms). These functions have been tested and they seem to be working properly. I want to add a description of these function and their arguments therefore, based on this question on the topic, I tried to code some subroutines that would achieve that:





      • First, I created a subroutine to actually encapsulate the descriptions:



        Sub RegisterUDF()

        myFunctionOneDescription = "Long FunctionOne description" & vbLf _
        & "myFunctionOne(<...>, ..., <...>)"
        myFunctionOneArguments = Array("FunctionOne argument 1 description", _
        "FunctionOne argument 2 description", _
        "FunctionOne argument 3 description", _
        "FunctionOne argument 4 description", _
        "[Optional] FunctionOne argument 5 description")

        myFunctionTwoDescription = "Long FunctionTwo description" & vbLf _
        & "myFunctionTwo(<...>, ..., <...>)"
        myFunctionTwoArguments = Array("FunctionTwo argument 1 description", _
        "FunctionTwo argument 2 description", _
        "FunctionTwo argument 3 description", _
        "FunctionTwo argument 4 description", _
        "[Optional] FunctionTwo argument 5 description")

        myFunctionThreeDescription = "Long FunctionThree description" & vbLf _
        & "myFunctionThree(<...>, ..., <...>)"
        myFunctionThreeArguments = Array("FunctionThree argument 1 description", _
        "FunctionThree argument 2 description", _
        "FunctionThree argument 3 description", _
        "FunctionThree argument 4 description", _
        "[Optional] FunctionThree argument 5 description")

        Application.MacroOptions Macro:="myFunctionOne", Description:=myFunctionOneDescription, ArgumentDescriptions:=myFunctionOneArguments, Category:=9
        Application.MacroOptions Macro:="myFunctionTwo", Description:=myFunctionTwoDescription, ArgumentDescriptions:=myFunctionTwoArguments, Category:=9
        Application.MacroOptions Macro:="myFunctionThree", Description:=myFunctionThreeDescription, ArgumentDescriptions:=myFunctionThreeArguments, Category:=9

        End Sub



      • Then, I create the following subroutine in the ThisWorkbook object:



        Private Sub Workbook_Open()
        Call RegisterUDF
        End Sub


        so that the descriptions are automatically loaded when I open the workbook.




      When creating these two subroutines and assessing the look of the function descriptions in the Function UI (namely the one that pops up when you press Ctrl+Shift+A or fx), I started closing and reopening the workbook given descriptions are updated only when Workbook_Open() is executed. Then, at some point I started getting an Out of Memory error immediately after opening the workbook; the error seemed to originate from the third function description above:





      I started getting rid of these two subroutines but now I still see the Out of Memory error when I refresh my workbook (whose tabs are populated with instances of my user-defined functions); each time, the Out of Memory error seems to originate in one of my UDFs but not always the same. In addition, when I try to cancel the debugging by resetting VBA, I get a new Out of Memory error immediately after, before having refreshed the workbook or performed any additional action, thus I end trapped in a "loop" of Out of Memory errors and I am forced to close Excel from the Task Manager (1). This had never happened before I tried to code the functions' descriptions.



      Can anybody help me in understanding what might be going on? I suspect this is related to the utilisation of Application.MacroOptions but I am unsure. Any help is greatly appreciated.



      (1) I suspect this is actually explained by the fact that, when I refresh the workbook or a tab, multiple instances of my UDFs will try to reevaluate hence each Out of Memory error corresponds to one instance of my UDFs.



      [EDIT #1] I observe very strange behaviour. For example, on a tab with preexisting instances of my UDFs in some cells, I have tried to evaluate one of my functions in a new cell after having commented out the 2 subroutines described above. When writing down the function in the cell and pressing enter, I got the Out of Memory error originating from the code of that UDF. Then, I deleted from the VBA code the commented subroutines and when pressing enter the function evaluated correctly! However, when refreshing that tab, I then got the same memory error but this time coming from another UDF.







      excel vba out-of-memory user-defined-functions






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 25 '18 at 19:20







      Daneel Olivaw

















      asked Nov 25 '18 at 13:24









      Daneel OlivawDaneel Olivaw

      4061717




      4061717
























          1 Answer
          1






          active

          oldest

          votes


















          0














          This seems to have been solved by following the procedure outlined below(1):




          1. Delete subroutines RegisterUDF() from module and Workbook_Open() from Workbook object;

          2. Copy all the VBA code from the module(2) into e.g. the notepad;

          3. Delete the workbook's module;

          4. Create a new module in the same workbook;

          5. Paste code into new module.


          The Out of Memory errors have ceased after this manipulation, however I still do not know what the origin was in the first place, and I am not sure whether this could happen again if I try to reprogram RegisterUDF() and Workbook_Open(). Any additional explanation to this bug is greatly appreciated.



          (1) Other tricks, such as copying the whole workbook; restarting the computer; copying/pasting the code to a new workbook without deleting the old module from the original workbook; etc. did not seem to solve the issue.



          (2) All my code was located in a single module.






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53467927%2fout-of-memory-vba-error-after-trying-to-register-descriptions-of-udfs%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            This seems to have been solved by following the procedure outlined below(1):




            1. Delete subroutines RegisterUDF() from module and Workbook_Open() from Workbook object;

            2. Copy all the VBA code from the module(2) into e.g. the notepad;

            3. Delete the workbook's module;

            4. Create a new module in the same workbook;

            5. Paste code into new module.


            The Out of Memory errors have ceased after this manipulation, however I still do not know what the origin was in the first place, and I am not sure whether this could happen again if I try to reprogram RegisterUDF() and Workbook_Open(). Any additional explanation to this bug is greatly appreciated.



            (1) Other tricks, such as copying the whole workbook; restarting the computer; copying/pasting the code to a new workbook without deleting the old module from the original workbook; etc. did not seem to solve the issue.



            (2) All my code was located in a single module.






            share|improve this answer




























              0














              This seems to have been solved by following the procedure outlined below(1):




              1. Delete subroutines RegisterUDF() from module and Workbook_Open() from Workbook object;

              2. Copy all the VBA code from the module(2) into e.g. the notepad;

              3. Delete the workbook's module;

              4. Create a new module in the same workbook;

              5. Paste code into new module.


              The Out of Memory errors have ceased after this manipulation, however I still do not know what the origin was in the first place, and I am not sure whether this could happen again if I try to reprogram RegisterUDF() and Workbook_Open(). Any additional explanation to this bug is greatly appreciated.



              (1) Other tricks, such as copying the whole workbook; restarting the computer; copying/pasting the code to a new workbook without deleting the old module from the original workbook; etc. did not seem to solve the issue.



              (2) All my code was located in a single module.






              share|improve this answer


























                0












                0








                0







                This seems to have been solved by following the procedure outlined below(1):




                1. Delete subroutines RegisterUDF() from module and Workbook_Open() from Workbook object;

                2. Copy all the VBA code from the module(2) into e.g. the notepad;

                3. Delete the workbook's module;

                4. Create a new module in the same workbook;

                5. Paste code into new module.


                The Out of Memory errors have ceased after this manipulation, however I still do not know what the origin was in the first place, and I am not sure whether this could happen again if I try to reprogram RegisterUDF() and Workbook_Open(). Any additional explanation to this bug is greatly appreciated.



                (1) Other tricks, such as copying the whole workbook; restarting the computer; copying/pasting the code to a new workbook without deleting the old module from the original workbook; etc. did not seem to solve the issue.



                (2) All my code was located in a single module.






                share|improve this answer













                This seems to have been solved by following the procedure outlined below(1):




                1. Delete subroutines RegisterUDF() from module and Workbook_Open() from Workbook object;

                2. Copy all the VBA code from the module(2) into e.g. the notepad;

                3. Delete the workbook's module;

                4. Create a new module in the same workbook;

                5. Paste code into new module.


                The Out of Memory errors have ceased after this manipulation, however I still do not know what the origin was in the first place, and I am not sure whether this could happen again if I try to reprogram RegisterUDF() and Workbook_Open(). Any additional explanation to this bug is greatly appreciated.



                (1) Other tricks, such as copying the whole workbook; restarting the computer; copying/pasting the code to a new workbook without deleting the old module from the original workbook; etc. did not seem to solve the issue.



                (2) All my code was located in a single module.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 25 '18 at 19:20









                Daneel OlivawDaneel Olivaw

                4061717




                4061717






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53467927%2fout-of-memory-vba-error-after-trying-to-register-descriptions-of-udfs%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Contact image not getting when fetch all contact list from iPhone by CNContact

                    count number of partitions of a set with n elements into k subsets

                    A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks