Executing Userform

G

Guest

I am new to userforms. I have a command button with caption of "Begin New
Order" which clears out form and places cursor in B1. I would like to have
it also call up a userform.

Below is the current code for the command button:
Private Sub CommandButton2_Click()
Range("B1:B3").Value = ""
Range("D6:H8").ClearContents
Range("A13:B90").ClearContents
Range("C13:C90").Value = ""
Range("B1").Select
End Sub

Below is the code for the userform:
Public Sub Stationform()
Dim station As String
Dim crew As String
Dim D As Date
Dim st As New STINFO
st.Show
station = st.txtST.Value
crew = st.txtCrew.Value
D = st.txtDate.Value
Range("B1").Value = station
Range("B2").Value = crew
Range("B3").Value = D
End Sub

How can I call up the userform within the execution of the commandbutton?

Thanks, and Happy Thanksgiving.

Les
 
G

Guest

Private Sub CommandButton2_Click()
Range("B1:B3").Value = ""
Range("D6:H8").ClearContents
Range("A13:B90").ClearContents
Range("C13:C90").Value = ""
Range("B1").Select
StationForm
End Sub


Public Sub Stationform()
Dim station As String
Dim crew As String
Dim D As Date
Dim st As New STINFO
st.Show
station = st.txtST.Value
crew = st.txtCrew.Value
D = st.txtDate.Value
Range("B1").Value = station
Range("B2").Value = crew
Range("B3").Value = D
st.Show
End Sub

would be my guess.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top