+ Reply to Thread
Results 1 to 7 of 7

Passing subroutine as a parameter

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-25-2008
    Location
    texas
    Posts
    178

    Re: Passing subroutine as a parameter

    I am still getting errors:

    My code is
    Sub day1move()
     rundailyloadroutine "loadoverroutine", 7
    End Sub
    
    Sub rundailyloadroutine(a, b)
     Run a(b)
    End Sub
    
    Sub loadoverroutine()
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
    End Sub
    but I get a "runtime error 13 type mismatch on the "run a(b).
    and a "compile error. expected sub,function,or property" fif I try call a(b)

    Thanks guys

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Passing subroutine as a parameter

    loadoverroutine had no argument which meant even after correcting the Run command it would still fail.

    Either add the argument to the loadoverroutine routine header or
    remove b from the Run command.

    Sub rundailyloadroutine(a, b)
     Run a, b
    End Sub
    
    Sub loadoverroutine(b)
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
    End Sub
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Contributor
    Join Date
    07-25-2008
    Location
    texas
    Posts
    178

    Re: Passing subroutine as a parameter

    That did it. A.P. is the man.

    Thanks.

    I love asking questions on this forum because I know there is going to be a remarkable solution.

+ 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