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

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

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.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,071
Messages
5,835,216
Members
430,347
Latest member
Mayan

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