Results 1 to 6 of 6

Thread: REFERENCING A VARIABLE FORM NAME

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Tutor MINCUS1308's Avatar
    Joined
    Jun 2014
    Location
    UNDER MY DESK
    Posts
    254

    REFERENCING A VARIABLE FORM NAME

    ' I HAVE TWO FORMS: Macro1 AND Macro2.
    ' BOTH HAVE A TEXTBOX NAMED: TextBox1 ON THEM.
    ' CAN I CALL A FUNCTION: RandomFunctions(VariableForm)
    ' AND TAKE THE DATA FROM A VARIABLE FORM'S (I.E. Macro1 OR Macro2)
    ' CORESPONDING TEXTBOX: TextBox1 AND PLACE IT
    ' INTO CELL A1 ON Sheet1?



    Sub Macro1()
        VariableForm = "Macro1"
        Call RandomFunctions(VariableForm)
    End Sub
    
    
    Sub Macro2()
        VariableForm = "Macro2"
        Call RandomFunctions(VariableForm)
    End Sub
    
    
    Sub RandomFunctions(VariableForm)
    
    
        Sheets("Sheet1").Range("A1").Value = VariableForm.TextBox1.Value
        
    End Sub
    Last edited by Bob Phillips; 06-25-2014 at 02:49 AM. Reason: Added VBA tags

Tags for this Thread

Posting Permissions

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