Results 1 to 6 of 6
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    La Jolla, CA
    Posts
    1,470
    Thanks
    30
    Thanked 62 Times in 58 Posts

    Macro run from another macro

    I have a simple macro in a module called “CommRept” that I want to run from another macro.
    When I run it by itself, it works just fine. I’ve tried:

    Application.Run(“CommRept”) and also Call CommRept and neither of them execute it and I don't get an error (either).

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Kevin,

    How is the CommRept macro declared, e.g.:

    Sub CommRept or Private Sub CommRept ?

    Where is the CommRept macro located, e.g.: Standard Module, Workbook Module, WorkSheet Module?

    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    La Jolla, CA
    Posts
    1,470
    Thanks
    30
    Thanked 62 Times in 58 Posts
    It's in Module 1 and it's a Sub CommRept().

  4. #4
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Then all you should need is:

    If in same module

    CommRept

    If calling from a different module change declaration to:

    Public Sub CommRept() {actually you shouldn't even need this if it is the same workbook}

    Then you can call as above.

    HTH
    Last edited by RetiredGeek; 2016-08-10 at 17:18.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  5. #5
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    La Jolla, CA
    Posts
    1,470
    Thanks
    30
    Thanked 62 Times in 58 Posts
    Stupid me. Of course that works providing I have the sheet selected! DUH.

  6. #6
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Kevin,

    If the macro requires a specific sheet to be selected that should be the first thing it tests and then either sets that sheet active, references it via a shtVar (Dim shtCurrent as Sheet), or messages the user and then halts.

    HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

Posting Permissions

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