How to limit cell entries only to dropdown menu (and nothing else)?

Rnkhch

Well-known Member
Joined
Apr 28, 2018
Messages
528
Office Version
  1. 365
Platform
  1. Windows
Hello,

I thought this would be straightforward or already answered somewhere on the web, but I couldn't get a clear answer.

My impression was that defining a dropdown menu list for cell data validation would restrict cell entries only to items from that menu. But to my surprise I found out today that in addition to those dropdown items, I could type in anything else that I wanted to 😱. (My dropdown menu is designed so well that it gives the students the options from 1,2,3, and 4 and every time one of these are selected, the remaining cells don't show that number, so if 1 is selected, then only 2,3,4, remain for the subsequent cells.) But one of my students showed me today that not only numbers from 1 to 4, but anything else (even letters etc.) can also be typed in there as if the data validation dropdown wasn't even there🤦‍♂️.

Any ideas why this is the case? Am I missing anything 🧐? Any solutions?

Please direct me to any posts address this if available.

(P.S. I can define conditional formatting to highlight cells that get anything besides 1,2,3, or 4, but still it doesn't make sense that the dropdown doesn't take care of the situation by itself)
 
Last edited:

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Is the "Show error alert after invalid data is entered" tickbox checked under the Daata Validation Error Alert tab?

Sans titre.png
 
Upvote 0
Yes, it is checked.

It appears that it doesn't recognize the invalid entries as invalid. The List comes from a defined name that I put in the 'source' box. The defined name is a formula that points back to a range using the basic =cell:INDEX(range,COUNT(range)) formula.
 
Upvote 0
What formula are you using for the defined name? Have you locked the rows and cells, e.g.

MyDataValidation: =Sheet1!$A$1:INDEX(Sheet1!$A:$A,COUNT(Sheet1!$A:$A))

Also, are the data validation values numeric, e.g. 1 rather than "1", or should you be using COUNTA rather than COUNT?
 
Upvote 0
It's a bit of a complicated formula (actually you helped me with the formula a few weeks ago :biggrin:) Here is the formula which I have actually defined as a LAMBDA function in the most recent version of my file:

=LAMBDA(sample_checker,IF((ISNUMBER(sample_checker)),(LET(x,INDEX(INDIRECT("Control!$DL$1:$DP$"&Control!$CY$1),sample_checker,),OFFSET(x,,,,COUNT(x+1)))),(Control!$H$1)))

All values are numeric. Another function checks to see how many sample replicates are already selected, and if any is selected they are removed from the range DL:DP. At the end when all possible replicates are selected, then it points to Control!$H$1 which is a blank cell and the dropdown shows a blank, meaning no more replicates are available to be selected.
 
Last edited:
Upvote 0
For context, here's that previous thread: Is there a problem with this INDIRECT statement?

The example below illustrates the creation of a list 18,19, which you wanted to use for data validation without the additional zeros showing.

I don't know exactly how you're creating your current DV list, but I have shown two possibilities. Both cell drop downs show that only 18,19 are permitted, but the first cell actually permits any value to be entered, i.e. matching your experience.

ABCDEF
1Sample
2123
34567
489
510111213
614151617
71819
8LastRow202122
992324
10
11InOut
12Our previous thread --->61819
13
14Your variation -->61819
15
16sample_checker6
17
18Data validation
19 =MyLambda(sample_checker) <-- accepts any value
20 =MyDV <-- accepts only 18,19
Sheet1
Cell Formulas
RangeFormula
B9B9=ROW(C9)
D12:E12D12=LET(x,INDEX($C$2:$F$9,C12,),OFFSET(x,,,,COUNT(x)))
D14:E14D14=MyLambda(C14)
Dynamic array formulas.
Named Ranges
NameRefers ToCells
LastRow=Sheet1!$B$9D14
MyDV=MyLambda(sample_checker)D12
Cells with Data Validation
CellAllowCriteria
C19List=MyLambda(sample_checker)
C20List=MyDV

sample_checker: =Sheet1!$C$16
MyLambda: =LAMBDA(a,LET(x,INDEX(INDIRECT("Sheet1!$C$2:$F$" & LastRow),a,),OFFSET(x,,,,COUNT(x))))

1657674427915.png
 
Upvote 0
Thank you so much for the detailed sample! Appreciate your time.

I was trying to understand why MyDV works but not MyLambda. Could you please explain the mechanics of the differences between the two? (MyLamda directly points to the range anyways, but MyDV adds another selective layer.)

(In my case, the range that MyLamda points to is dynamically changing rather than fixed numbers like your example. So I'm wondering if this has any effect on the issue that I'm experiencing as well, but I'll wait for your explanation.)
 
Upvote 0
Could you please explain the mechanics of the differences between the two?

Ha! Who can explain the sometimes apparently capricious, but no doubt subtle and divine workings.

We can only humbly accept that it's Excel's will.
 
Upvote 0
I see :biggrin: ok, I'll try to apply your suggestion to my file and see if I get it to work like you did.

Thanks!
 
Upvote 0
By the way, Post #6 was mostly about me trying to replicate your problem. There may be other more direct fixes.

Do you even need to use a Lambda? Consider, for example:

ABCDEFGH
1Sample
2123
34567
489
510111213
614151617
71819
8202122
92324
10DV2
11MyDV21231
124567
13
Sheet1
Cell Formulas
RangeFormula
C11:E11,C12:F12C11=LET(x,INDEX($C$2:$F$9,ROWS($C$11:$C11),),OFFSET(x,,,,COUNT(x)))
Dynamic array formulas.
Named Ranges
NameRefers ToCells
MyDV2=LET(x,INDEX(Sheet1!$C$2:$F$9,ROWS(Sheet1!$C$11:$C11),),OFFSET(x,,,,COUNT(x)))C11:C12
Cells with Data Validation
CellAllowCriteria
H11:H12List=MyDV2

MyDV2 (defined when cursor in row 11): =LET(x,INDEX(Sheet1!$C$2:$F$9,ROWS(Sheet1!$C$11:$C11),),OFFSET(x,,,,COUNT(x)))

1657682743883.png
 
Upvote 0
Solution

Forum statistics

Threads
1,213,585
Messages
6,114,518
Members
448,575
Latest member
hycrow

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