Validating entry in user form

Debo333

New Member
Joined
Oct 18, 2006
Messages
11
Hello,

I am trying to force entry into a user form after a comman button OKclick which performs a series of functions.

If a textbox is empty I want a msgbox to pop up telling the user to please enter "name" for example. When using If txtname.value = "" then msgbox"please enter a name" after the message box ok button is clicked the macro continues. Ideally the sub should end or "pause" and a pH value entered, forcing the user to click the commandbuttonOk again. Please let me know if you can help! Thank you for your time.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Awesome, I knew I had the right idea but am new to VB so I consistently struggle with the text.


Thanks Much!
 
Upvote 0
Hello,

Does anyone know the code to prevent the user from advancing to the next entry without making an entry? (setfocus? maybe) I have the same situation as Debo333 and the msg comes up fine telling user to enter a name, but you can tab to the next entry. I would like a code that prevents user from moving forward until an entry has been made. Thanks.
 
Upvote 0
micromagnet

Why don't you create a new thread?
 
Upvote 0
Thanks Norie for the input. I thought it might be easier to add to this thread, plus I don't know how to reference a past thread. Anyway, I was able to figure out the code. For those needing:

Cancel = True
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,901
Members
449,097
Latest member
dbomb1414

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