+ Reply to Thread
Results 1 to 8 of 8

count procedure calls..........

  1. #1
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,669

    count procedure calls..........

    Hi, is there a way in excel vba to count the number of time a procedure/function gets called?

    trying to update some code and i want to remove those procedures which are not used any longer.

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,318

    Re: count procedure calls..........

    Are you referring to different Subs within a module?
    HTH
    Regards, Jeff

  3. #3
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,669

    Re: count procedure calls..........

    yes..... subs in a given module

  4. #4
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,318

    Re: count procedure calls..........

    My thought would be to use a counter within the sub and write the value to a cell on a sheet to see how many time that sub was called.

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: count procedure calls..........

    Hi welchs101,

    You can also declare a Global Variable that you can use as a counter. Each time you enter a Sub or Function you would increment the global variable that counts the number of times that code is run. See Global Variable at http://www.cpearson.com/excel/scope.aspx
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  6. #6
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,669

    Re: count procedure calls..........

    actually those are good ideas......

    i have some code...........i had to make some MAJOR changes to the code.......now there are subs which i am no longer using..........so those that i am no longer using i want to get rid of............

    i have a lot of subs.......i would rather not put code in each sub to count if its used...........if i was going to do that i would just go to each sub and do a find on its name.....to see if its being called anywhere.......

    i was just hoping VBA would have a function that indicates what subs were being called by the program and which were not.......

  7. #7
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: count procedure calls..........

    Hi Welchs101,

    I've installed two add-ins that help with my code and discovering stuff about my workbooks.
    Look at: http://www.mztools.com/v3/mztools3.aspx and http://spreadsheetpage.com/index.php/pupv7/home
    I'm not sure either has a Procedure hit counter but both have other useful tools to help in making better code and sheets.

  8. #8
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,669

    Re: count procedure calls..........

    thanks. I will check this out.

+ 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