+ Reply to Thread
Results 1 to 3 of 3

Call procedure using variable

  1. #1
    donbowyer
    Guest

    Call procedure using variable

    I need use an expression, which has been derived as a variable in a code
    procedure, to call a Subroutine of the same name.
    The Sub Routine will have a name eg MyZ7 derived from:-
    MyName="My" & Range("A1").Value where A1 contains "Z7"
    this produces "MyZ7" OK but the problem is that if I now write:-
    "Call MyName" I get an error message "Compile Error expected Procedure not
    Variable"
    There must be a way around this: help please
    --
    donwb

  2. #2
    Dave Peterson
    Guest

    Re: Call procedure using variable

    One way:

    application.run thisworkbook.name & "!" & myname

    Is Thisworkbook ok?

    donbowyer wrote:
    >
    > I need use an expression, which has been derived as a variable in a code
    > procedure, to call a Subroutine of the same name.
    > The Sub Routine will have a name eg MyZ7 derived from:-
    > MyName="My" & Range("A1").Value where A1 contains "Z7"
    > this produces "MyZ7" OK but the problem is that if I now write:-
    > "Call MyName" I get an error message "Compile Error expected Procedure not
    > Variable"
    > There must be a way around this: help please
    > --
    > donwb


    --

    Dave Peterson

  3. #3
    donbowyer
    Guest

    Re: Call procedure using variable

    Hi Dave
    That works perfectly.
    Many thanks

    --
    donwb


    "Dave Peterson" wrote:

    > One way:
    >
    > application.run thisworkbook.name & "!" & myname
    >
    > Is Thisworkbook ok?
    >
    > donbowyer wrote:
    > >
    > > I need use an expression, which has been derived as a variable in a code
    > > procedure, to call a Subroutine of the same name.
    > > The Sub Routine will have a name eg MyZ7 derived from:-
    > > MyName="My" & Range("A1").Value where A1 contains "Z7"
    > > this produces "MyZ7" OK but the problem is that if I now write:-
    > > "Call MyName" I get an error message "Compile Error expected Procedure not
    > > Variable"
    > > There must be a way around this: help please
    > > --
    > > donwb

    >
    > --
    >
    > Dave Peterson
    >


+ 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