MsgBox Replacement w/ an UserForm

C

Chuckles123

Sub ShowForm()
Dim Button As String
frmPricing_Options_UserForm.Show
If Button = "EVAL" Then
Range("A1").Select
Else
Range("C1").Select
End If
End Sub

Private Sub optEval_Prices_Click()
Button = "EVAL"
Unload Me
End Sub

Private Sub optBid_Prices_Click()
Button = "BID"
Unload Me
End Sub

When the macro is executed, Cell C1 is selected even when the EVA
Option Button is clicked.

Thanks again,
Chuckles12
 
B

Bob Phillips

Okay, that is easy.

Because you Don't declare the Button variable as a global variable, the
option button routines are not setting the variable you think they are, but
rather an implicit Form class variable called Button.

In you standard code module, change the ShowForm code to this

Public Button As String

Sub ShowForm()frmPricing_Options_UserForm.Show
If Button = "EVAL" Then
Range("A1").Select
Else
Range("C1").Select
End If
End Sub
 
M

Mike Fogleman

It seems you are setting Button="EVAL" in a Private Sub and trying to
use that in a general module Dimmed within a procedure.
Try - Public Button As String - at the top of the general module.

Mike F
 

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