Results 1 to 7 of 7

Thread: Sub is this possible

  1. #1
    Moderator mole999's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    9,873
    Post Thanks / Like
    Mentioned
    16 Post(s)
    Tagged
    2 Thread(s)

    Default Sub is this possible

    I'm having a big problem with a set of routines (I won't explain them) Is it possible to call a routine from a Sub, and return the ID of the calling Sub (maybe its not worth doing) I want to list each sub entry and a time stamp to be able to focus down on what the issue is

    Sub One
    Reporting
    End Sub

    Sub Two
    Reporting
    End Sub


    Sub Reporting
    Last Row of reporting page
    stamp with calling Sub (ID) and time stamp
    End Sub

    One 07:00:01
    Two 07:00:02
    • Yes I know there are better ways to do it. I just wish I knew them. - 97, 2003, 2007, 2010, 2013, 2016 & 2019
    • I wear my ignorance openly, excel is not my chosen career, its a means to an ends
    • Posting Guidelines Want to post well laid out questions and answers Translate Excel Versions
      Code:
      [CODE ]Put Your Code[/ CODE]
    • Settings > General Settings (on the left) scroll to the bottom, > Miscellaneous Options > Use ENHANCED
    • X-Posting Guidelines Rule 13 > CHART STUFF

  2. #2
    MrExcel MVP AlphaFrog's Avatar
    Join Date
    Sep 2009
    Posts
    16,102
    Post Thanks / Like
    Mentioned
    17 Post(s)
    Tagged
    7 Thread(s)

    Default Re: Sub is this possible

    Code:
    Sub One()
    Reporting "One"
    End Sub
    
    
    Sub Two()
    Reporting "Two"
    End Sub
    
    
    Sub Reporting(strCaller)
    'Last Row of reporting page
    'stamp with calling Sub (ID) and time stamp
    Debug.Print strCaller & ", " & Now
    End Sub
    Paste your Excel data to the forum...
    MrExcel HTML Maker or Excel Jeanie

    How to post your vba code
    [CODE]your VBA code here[/CODE]
    The # button in the forum's editor will apply CODE tags around your selected text.

  3. #3
    Moderator mole999's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    9,873
    Post Thanks / Like
    Mentioned
    16 Post(s)
    Tagged
    2 Thread(s)

    Default Re: Sub is this possible

    Thank you, I didn't know what to search for
    • Yes I know there are better ways to do it. I just wish I knew them. - 97, 2003, 2007, 2010, 2013, 2016 & 2019
    • I wear my ignorance openly, excel is not my chosen career, its a means to an ends
    • Posting Guidelines Want to post well laid out questions and answers Translate Excel Versions
      Code:
      [CODE ]Put Your Code[/ CODE]
    • Settings > General Settings (on the left) scroll to the bottom, > Miscellaneous Options > Use ENHANCED
    • X-Posting Guidelines Rule 13 > CHART STUFF

  4. #4
    Board Regular
    Join Date
    Dec 2009
    Posts
    288
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Sub is this possible

    It seems like that might miss the point Alpha. It seems like they were trying to figure out if there was a way to programatically figure out the sub name so they could just use

    Code:
    Sub One()
    Reporting "thisSub.name"
    End Sub"
    
    Sub Reporting (strCaller)
    Debug.print strCaller & ", " & Now"
    End Sub
    and paste in
    Code:
    Reporting "thisSub.name"
    to each sub without having to manually update the sub name.

    EDIT---> I take it back. They seem happy with that. OP Seems happy with that. My bad.
    Last edited by =ODIN=; Sep 28th, 2019 at 04:23 AM.
    My favorite Excel Add-in:= Nutilities

  5. #5
    Moderator mole999's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    9,873
    Post Thanks / Like
    Mentioned
    16 Post(s)
    Tagged
    2 Thread(s)

    Default Re: Sub is this possible

    Quote Originally Posted by =ODIN= View Post
    It seems like that might miss the point Alpha. It seems like they were trying to figure out if there was a way to programatically figure out the sub name so they could just use

    Code:
    Sub One()
    Reporting "thisSub.name"
    End Sub"
    
    Sub Reporting (strCaller)
    Debug.print strCaller & ", " & Now"
    End Sub
    and paste in
    Code:
    Reporting "thisSub.name"
    to each sub without having to manually update the sub name.

    EDIT---> I take it back. They seem happy with that. OP Seems happy with that. My bad.
    No need to take it back, having options is always useful. the single use sub identifier is what I am after, easy to comment out or in globally
    • Yes I know there are better ways to do it. I just wish I knew them. - 97, 2003, 2007, 2010, 2013, 2016 & 2019
    • I wear my ignorance openly, excel is not my chosen career, its a means to an ends
    • Posting Guidelines Want to post well laid out questions and answers Translate Excel Versions
      Code:
      [CODE ]Put Your Code[/ CODE]
    • Settings > General Settings (on the left) scroll to the bottom, > Miscellaneous Options > Use ENHANCED
    • X-Posting Guidelines Rule 13 > CHART STUFF

  6. #6
    Board Regular
    Join Date
    Dec 2009
    Posts
    288
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Sub is this possible

    After a bit of googling it seems like there is no way in vba to programitcally get thisSub.name. The great Chip Pearson’s website even has a page about it: http://www.cpearson.com/excel/InsertProcedureNames.aspx
    My favorite Excel Add-in:= Nutilities

  7. #7
    Moderator mole999's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    9,873
    Post Thanks / Like
    Mentioned
    16 Post(s)
    Tagged
    2 Thread(s)

    Default Re: Sub is this possible

    Thank you for the research. I had started to implement a label by label identifier. It has shown some issues which have been corrected
    • Yes I know there are better ways to do it. I just wish I knew them. - 97, 2003, 2007, 2010, 2013, 2016 & 2019
    • I wear my ignorance openly, excel is not my chosen career, its a means to an ends
    • Posting Guidelines Want to post well laid out questions and answers Translate Excel Versions
      Code:
      [CODE ]Put Your Code[/ CODE]
    • Settings > General Settings (on the left) scroll to the bottom, > Miscellaneous Options > Use ENHANCED
    • X-Posting Guidelines Rule 13 > CHART STUFF

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •