Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Walter L. skinner
 
Posts: n/a
Default Create and Use Button Menu using visual Basic in Excel

The following code is very simple. All I need to do is figure out how get the
result of the userform entry from the click event. I apologize if seems to
easy but I have trouble with userforms and menus getting user data.
Thanks for Your Help

Sub test()
UserForm1.show
If Me.OptionButton1 = "True" Then
Debug.Print "Option One has been Selected"
Else
Debug.Print "This has failed miserably"
End If
End Sub


Private Sub OptionButton1_Click()
Dim Sel As String
Unload Me
MsgBox ("You Select Buton 1")
Sel = Me.OptionButton1
End Sub

Private Sub OptionButton2_Click()
Unload Me
MsgBox ("You Select Buton 2")
Unload Me
End Sub

Private Sub OptionButton3_Click()
MsgBox ("You Select Buton 3")
Unload Me
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default Create and Use Button Menu using visual Basic in Excel

Walter,

Are you trying to use a bit of code to show a form and then test what
control was invoked, from within the original code? If so, I think you have
a problem, as control will not pass back to that code (the IF statement)
until the form is closed, either hidden or unloaded,.

What exactly is the purpose of what you are trying to do.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Walter L. skinner" wrote in
message ...
The following code is very simple. All I need to do is figure out how get

the
result of the userform entry from the click event. I apologize if seems to
easy but I have trouble with userforms and menus getting user data.
Thanks for Your Help

Sub test()
UserForm1.show
If Me.OptionButton1 = "True" Then
Debug.Print "Option One has been Selected"
Else
Debug.Print "This has failed miserably"
End If
End Sub


Private Sub OptionButton1_Click()
Dim Sel As String
Unload Me
MsgBox ("You Select Buton 1")
Sel = Me.OptionButton1
End Sub

Private Sub OptionButton2_Click()
Unload Me
MsgBox ("You Select Buton 2")
Unload Me
End Sub

Private Sub OptionButton3_Click()
MsgBox ("You Select Buton 3")
Unload Me
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.misc
Walter L. skinner
 
Posts: n/a
Default Create and Use Button Menu using visual Basic in Excel

Bob: I have VB code that formats and defines a print area. What I need is an
input from the user telling me which header to use for the printout. I was
looking to use a list of buttons, wanting the user to select only one of
them. Then I would use that information to select the header in my code.

I thought I could envoke a user form displaying the choices and then on a
"click" event get the user data and transfer it from the private sub "Click"
to my code.

I think that explains what I want to do. If that is the wrong approach, I
would appreciate a good one.

Thanks

W. Skinner

"Bob Phillips" wrote:

Walter,

Are you trying to use a bit of code to show a form and then test what
control was invoked, from within the original code? If so, I think you have
a problem, as control will not pass back to that code (the IF statement)
until the form is closed, either hidden or unloaded,.

What exactly is the purpose of what you are trying to do.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Walter L. skinner" wrote in
message ...
The following code is very simple. All I need to do is figure out how get

the
result of the userform entry from the click event. I apologize if seems to
easy but I have trouble with userforms and menus getting user data.
Thanks for Your Help

Sub test()
UserForm1.show
If Me.OptionButton1 = "True" Then
Debug.Print "Option One has been Selected"
Else
Debug.Print "This has failed miserably"
End If
End Sub


Private Sub OptionButton1_Click()
Dim Sel As String
Unload Me
MsgBox ("You Select Buton 1")
Sel = Me.OptionButton1
End Sub

Private Sub OptionButton2_Click()
Unload Me
MsgBox ("You Select Buton 2")
Unload Me
End Sub

Private Sub OptionButton3_Click()
MsgBox ("You Select Buton 3")
Unload Me
End Sub




  #4   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default Create and Use Button Menu using visual Basic in Excel

Why not just a print button to the userform, and then add the code that you
already have in Test to that button's Click event, without the show?

Private Sub CommandButton1_Click()
If Me.OptionButton1 Then
'set print header 1
ElseIf Me.OptionButton2 Then
'set print header 2
Else
Debug.Print "This has failed miserably"
End If
End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Walter L. skinner" wrote in
message ...
Bob: I have VB code that formats and defines a print area. What I need is

an
input from the user telling me which header to use for the printout. I was
looking to use a list of buttons, wanting the user to select only one of
them. Then I would use that information to select the header in my code.

I thought I could envoke a user form displaying the choices and then on a
"click" event get the user data and transfer it from the private sub

"Click"
to my code.

I think that explains what I want to do. If that is the wrong approach, I
would appreciate a good one.

Thanks

W. Skinner

"Bob Phillips" wrote:

Walter,

Are you trying to use a bit of code to show a form and then test what
control was invoked, from within the original code? If so, I think you

have
a problem, as control will not pass back to that code (the IF statement)
until the form is closed, either hidden or unloaded,.

What exactly is the purpose of what you are trying to do.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Walter L. skinner" wrote in
message ...
The following code is very simple. All I need to do is figure out how

get
the
result of the userform entry from the click event. I apologize if

seems to
easy but I have trouble with userforms and menus getting user data.
Thanks for Your Help

Sub test()
UserForm1.show
If Me.OptionButton1 = "True" Then
Debug.Print "Option One has been Selected"
Else
Debug.Print "This has failed miserably"
End If
End Sub


Private Sub OptionButton1_Click()
Dim Sel As String
Unload Me
MsgBox ("You Select Buton 1")
Sel = Me.OptionButton1
End Sub

Private Sub OptionButton2_Click()
Unload Me
MsgBox ("You Select Buton 2")
Unload Me
End Sub

Private Sub OptionButton3_Click()
MsgBox ("You Select Buton 3")
Unload Me
End Sub






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 09:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"