Consulting

Results 1 to 2 of 2

Thread: Solved: Passing a variable

  1. #1
    VBAX Mentor
    Joined
    Nov 2008
    Posts
    305
    Location

    Solved: Passing a variable

    Can someone please help me with this code.
    [VBA]Sub sortall()
    mysort="G"
    sort
    End Sub

    Sub sort
    Dim e
    e= Range ("Sheet1!" & mysort & "5").Value
    'do some other stuff

    End Sub
    [/VBA]

    I just want mysort in the Sub sort to = whatever variable I pass to it in another part of the code.

    Thanks

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Sub sortall()
    sort "G"
    End Sub

    Sub sort( ByVal mysort As String)
    Dim e
    e= Range ("Sheet1!" & mysort & "5").Value
    'do some other stuff

    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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