+ Reply to Thread
Results 1 to 4 of 4

Pass sub variable to function

  1. #1
    Registered User
    Join Date
    07-13-2005
    Posts
    89

    Pass sub variable to function

    Hi and thanks in advance for any help.

    How can I pass a variable from a sub to a function? My codes are below:

    Sub Main()
    Dim Source, Dest
    Source = Z24
    Dest = T28
    SpecialFunc
    bla, bla, bla....
    End Sub

    Function SpecialFunc()
    Range(Source).Select
    bla, bla, bla....
    End Function

  2. #2
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by ledzepe
    Hi and thanks in advance for any help.

    How can I pass a variable from a sub to a function? My codes are below:

    Sub Main()
    Dim Source, Dest
    Source = Z24
    Dest = T28
    SpecialFunc
    bla, bla, bla....
    End Sub

    Function SpecialFunc()
    Range(Source).Select
    bla, bla, bla....
    End Function
    Hi,

    Please Login or Register  to view this content.
    should help you.

    ---
    Si fractum non sit, noli id reficere.

  3. #3
    Registered User
    Join Date
    07-13-2005
    Posts
    89
    How about passing two variables from a sub to a function? As in my earlier example:

    Sub Main()
    Dim Source, Dest
    Source = Z24
    Dest = T28
    SpecialFunc
    bla, bla, bla....
    End Sub

    Function SpecialFunc()
    Range(Source).Select
    Range(Dest).Select
    bla, bla, bla....
    End Function

    What I'm trying to accomplish is copying a cell to another cell. The cell positions move that is why I need to pass cell (source and destination) address variable to the function. If there's a better way, please tell me.

  4. #4
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by ledzepe
    How about passing two variables from a sub to a function? As in my earlier example:

    Sub Main()
    Dim Source, Dest
    Source = Z24
    Dest = T28
    SpecialFunc
    bla, bla, bla....
    End Sub

    Function SpecialFunc()
    Range(Source).Select
    Range(Dest).Select
    bla, bla, bla....
    End Function

    What I'm trying to accomplish is copying a cell to another cell. The cell positions move that is why I need to pass cell (source and destination) address variable to the function. If there's a better way, please tell me.
    Hi,

    as
    Please Login or Register  to view this content.
    hth
    ---

    btw, your earlier sub may have set two variables, but the Function only indicated using one of them.
    ---
    Last edited by Bryan Hessey; 12-06-2006 at 03:50 PM.

+ 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