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

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Debo333

New Member
Joined
Oct 18, 2006
Messages
11
Awesome, I knew I had the right idea but am new to VB so I consistently struggle with the text.


Thanks Much!
 

micromagnet

Board Regular
Joined
Jun 2, 2007
Messages
81
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.
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,300
Office Version
  1. 365
Platform
  1. Windows
micromagnet

Why don't you create a new thread?
 

micromagnet

Board Regular
Joined
Jun 2, 2007
Messages
81
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
 

Forum statistics

Threads
1,136,421
Messages
5,675,759
Members
419,585
Latest member
popsin

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