User form

jcaptchaos2

Well-known Member
Joined
Sep 24, 2002
Messages
1,026
Is there a way to prevent wrong data from being entered into a user form? For example if I had a table on and the user went to enter a number into a user form and that number wasn't in my table then it wouldn't let them enter it. It would give them some sort of error?
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,299
Office Version
  1. 365
Platform
  1. Windows
Why not use a combobox or listbox that only lists the valid numbers?

Or you could allow the user to enter a number then use Find or some other method to see if it's in the table.

If it's not tell the user and ask them to re-enter.:)
 

jcaptchaos2

Well-known Member
Joined
Sep 24, 2002
Messages
1,026
Sorry I am new at user forms, would I use ControlSource for that? If so could you give me an example?

Thanks
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,299
Office Version
  1. 365
Platform
  1. Windows
Not ControlSource, the property for populating is RowSource.

There are other ways to populate - List, AddItem etc - but if your unfamiliar with these type of controls RowSource is a good a place to start.

It should work fine as long as you are dealing with some sort of contiguous list of unique data.
 

jcaptchaos2

Well-known Member
Joined
Sep 24, 2002
Messages
1,026

ADVERTISEMENT

Thanks Norie, working on a large project so appreciate your help. I am sure you will see me around a lot in the next couple of weeks.

Can't thank you enough
JC
 

jcaptchaos2

Well-known Member
Joined
Sep 24, 2002
Messages
1,026

ADVERTISEMENT

Sorry if I use a combo box then I do
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,299
Office Version
  1. 365
Platform
  1. Windows
No problem, I actually had 2nd thoughts about if I'd used the right name.:)

In some apps it's RecordSource for example.

By the way you should probably avoid using ControlSource.

It has it's uses but if you want to get data from worksheet to userform and vice versa it's sometimes better to rely on a little bit of code.
 

jcaptchaos2

Well-known Member
Joined
Sep 24, 2002
Messages
1,026
Ok if you could help me one more time tonight, My list is on a sheet called "routings" and it goes from A2 - A700 so what do I type in RowSource?
 

Watch MrExcel Video

Forum statistics

Threads
1,133,760
Messages
5,660,791
Members
418,595
Latest member
PoloFacu

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