PDA

View Full Version : Get help for telling me how to code VBA to pass argument from Userform to worksheet



Francis2009
06-02-2009, 03:15 AM
Dear all,

Can anyone to tell me how I can pass agrument from coding of Userform to the coding of worksheet please?
The following coding shown on worksheet("sheet1")

Public Sub CommandButton3_Click()

Call UserForm3.PassMessage(PassGate)
UserForm3.Login_Name.Text = PassGate
If PassGate = 1 Then
ExchangeRate.Show
Else
UserForm3.Show
End If

End Sub

The following second coding shown on the userform
PassGate = 1
'Login_Name.Text = PassGate
PassMessage (PassGate)
Exit Do
Else
Message = MsgBox("The password is not correct!, try again please.", vbDefaultButton1)
Exit Do
Login_Name.Text = ""
PWD.Text = ""
End If
End If
'End If
a = a + 1
Loop
If i <> 1 Then
Message = MsgBox("There is no user name what you input, try an other user ID please.", vbDefaultButton1)
End If

End With
End Sub
Sub PassMessage(ByRef PassGate As Integer)

PassMessageOpen = PassGate
'Login_Name.Text = PassGate
End Sub

I do not why the complier that could not allow me to pass the argument from coding of userform to the coding of worksheet to show value on the object of textbox on worksheet("sheet1")

Could anyone to tell me how I can write a workable coding to fix this problem please?

Best regards,

Francis

shades
06-02-2009, 05:56 AM
Howdy and welcome to the board. I have to ask, is this specific to Mac versions of Excel?

Francis2009
06-02-2009, 06:50 PM
Dear Rich,

It's really VBA coding of Excel.

tpoynton
06-04-2009, 11:18 AM
you can then post in the regular excel forum, which gets more traffic than here. Posting a sample workbook with a description of what you are trying to accomplish will also help people help you.

Francis2009
06-04-2009, 10:36 PM
Dear tpoynton,

Many thanks for your suggestion.

mdmackillop
06-07-2009, 09:17 AM
Assuming you want Textbox data, you can add

Sheets("Sheet1").Range("A1") = Me.Textbox1.Text

Francis2009
06-07-2009, 10:22 PM
Dear VBAX Wizard,

I fixed the problem already, anyway thanks you very much for your reply.