UserInput equal to Cell then...

westc4

Board Regular
Joined
Aug 1, 2012
Messages
85
Office Version
  1. 365
Platform
  1. Windows
I need to write an If/Then statement using the UserInput box...

UserInputs the number 5
if cell B1 equals 5 then start UserForm2
else Message box1

It has been a few months since I worked with my VBA and I am pulling a blank....

Thank you for any help!
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
Is the user entering the value in a cell or via a first User Form?

If the former you can use:

Code:
Private Sub Worksheet_Calculate()
  If Range("B1").Value = 5 Then
     UserForm2.Show
  End if
End Sub

If the latter then something like this:

Code:
Private Sub TextBox1_AfterUpdate()
    If Range("B1").Value = 5 Then
        Unload Me
        UserForm2.Show
    End If
End Sub

HTH,
 

westc4

Board Regular
Joined
Aug 1, 2012
Messages
85
Office Version
  1. 365
Platform
  1. Windows
one more quick question.... how do I return to UserForm1 when my if/then statment fails? I do not want to continue to the next UserForm until inputbox = value in E1
 

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
The IF statement shouldn't unload form1 until it's true, so form1 should remain the active form.
 

Watch MrExcel Video

Forum statistics

Threads
1,129,357
Messages
5,635,797
Members
416,882
Latest member
ericvrealty

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top