Passing Variables Within Procedures On A Worksheet...

  • passing variables within procedures on a worksheet...


    i have:

    Code
    Private Sub lblGoToMaterials_Click()
    'email to:
    '----------------
    'grab current position
    myRow = ActiveCell.Row
    mycol = ActiveCell.Column


    and i would like to pass the values gotten in myRow and mycol to:

    Code
    Private Sub cmdGoBackTo_Click()
    Application.Goto Reference:="R" & myRow & "C" & mycol


    ???


    thank you...

  • Re: Passing Variables Within Procedures On A Worksheet...


    Looks like you are trying to communicate variables from one routine to another routine?


    If so, have you declared the MyRow and MyCol as public variables?


    If not, at the top of the module try:


    Code
    Public MyRow as variant
    Public Mycol as variant


    This will allow your second macro to retrive the data from the first one.


    Good luck!

  • Re: Passing Variables Within Procedures On A Worksheet...


    thank you...


    i added to the top of my vba editor for the sheet:

    Code
    Public MyRow As Variant
    Public Mycol As Variant


    ...the variables have the values when i click lblGoToMaterials, but they are empty when i click cmdGoBackTo...


    ???


    thanks...

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!