IF THEN with userform

jonathann3891

Board Regular
Joined
Apr 27, 2015
Messages
109
I have an if statement that checks the value of a certain cell before running the macro.

I want userform3 to hide or unload BEFORE showing the MsgBox.

Code:
If Sheets("PML").Range("E3").Value = "" ThenUserForm3.Hide
MsgBox "SELECT PILE SIZE", vbOKOnly, "MISSING DATA"
Userform1.Show
Else
 

Some videos you may like

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

KeepTrying

Active Member
Joined
Aug 19, 2012
Messages
272
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Hi,
Although I don't see full code I think you should use modeless when open UserForm3:

Code:
UserForm3.Show vbModeless

In this case "UserForm3.Hide" will work.

I hope that helps.

Regards,
 

jonathann3891

Board Regular
Joined
Apr 27, 2015
Messages
109
That should say

Code:
If Sheets("PML").Range("E3").Value = "" Then
UserForm3.Hide
MsgBox "SELECT PILE SIZE", vbOKOnly, "MISSING DATA"
Userform1.Show
Else
 

jonathann3891

Board Regular
Joined
Apr 27, 2015
Messages
109
Hi,
Although I don't see full code I think you should use modeless when open UserForm3:

Code:
UserForm3.Show vbModeless

In this case "UserForm3.Hide" will work.

I hope that helps.

Regards,

I think all my userforms should be modal. I dont want the user to do anything else until they click "OK" or "CANCEL"
 

KeepTrying

Active Member
Joined
Aug 19, 2012
Messages
272
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Hi,

Where did you put your code? If I add it to a module it doesn't work with modal userform. However if I assign code e.g. to a command button on Userform3 it works. Example:

Code:
Private Sub CommandButton1_Click()


If Sheets("PML").Range("E3").Value = "" Then
    UserForm3.Hide
    MsgBox "SELECT PILE SIZE", vbOKOnly, "MISSING DATA"
    UserForm1.Show
Else


End If


End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,123,493
Messages
5,601,998
Members
414,490
Latest member
Rip181

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