UserInput equal to Cell then...

westc4

Board Regular
Joined
Aug 1, 2012
Messages
89
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

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
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,
 
Upvote 0
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
 
Upvote 0
The IF statement shouldn't unload form1 until it's true, so form1 should remain the active form.
 
Upvote 0

Forum statistics

Threads
1,214,648
Messages
6,120,726
Members
448,987
Latest member
marion_davis

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
Back
Top