I'm trying to add Data Validation to 50 cells in a column that will only accept:
Alphanumeric
Hyphens (dashes)
No restrictions for length.
I did find some examples, but they are all for a single cell. If I try to change it to a range it breaks and won't let me save.
I tried this:
=ISNUMBER(SUMPRODUCT(SEARCH(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1),"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-")))
Which works for cell A1. However, if I change A1 to anything else - it won't let me even save the formula. And I need a range instead - O2:O50.
Here is how I am trying to do it:
Select a range of cells I need apply validation to, which O2:O50
Click on Data Validation
Select Custom Data validation and enter a formula above into the Formula entry.
Thank you so much in advance!
Someone suggested me an answer on a different website.
Select cells I need to apply validation to, in my case O2:O50.
Then in validation add this formula:
=ISNUMBER(SUMPRODUCT(SEARCH(MID(UPPER(O2),SEQUENCE(,LEN(O2)),1),"0123456789ABCDEFGHIJKL
Similar was suggested by the comment above!
Related
I am trying to use conditional formatting but I am running in to issues.
I have a single range which is populated based on user selection for an ActiveX ComboBox. What I am trying to do is highlight rows if the single range of cells contains duplicate values, but if the cell is blank, contains the word "Value", or does not match another cell in the range then leave the cell and row as is.
Basically if Cell B4 equals B46 then highlight both rows.
I have tried the following formulas with no success.
=IF(AND($B$4:$B$50="",$B$4:$B$50="Value"),0,COUNTIF($B$4:$B$50,$B$4:$B$50,0))
=IF(AND($B$4:$B$50="",$B$4:$B$50="Value"),0,MATCH($B$4:$B$50:$B$4:$B$50,0))
=IF(AND($B$4:$B$50="",$B$4:$B$50="Value"),0,IF($B$4:$B$50=$B$4:$B$50,1,0))
I'm still learning excel and could use some help on this. Thanks in advance!
Eric
I suspect what you want is a CF formula rule something like:
=AND(NOT(OR(B4="",B4="Value")),COUNTIF(B$4:B$50,B4)>1)
applied to B4:B50.
Thank you everyone who provided a response. I was able to develop a solution that worked based on your responses. The following is the solution I used:
1.) Created a conditional format highlighting duplicate values.
2.) Created a conditional format using the below formula to highlight duplicate rows, ignore blank rows, and ignore rows with "Value" in cell B4:
=AND(COUNTIF($B$4:$B$63,$B4)>1,LEN($B4)>0,LEN($B4)-4>0)
Thank you once again for everyone's assistance.
Eric
I'm sorry if I put this question in the wrong section, because it is not entirely focussed on programming. But I don't know where to put it else.
I have the following rule as data validation for a particular cell in Excel:
=INDIRECT($D$5)
I want to copy this data validation rule to other cells. However, when I copy/paste the cell, it literally pastes the value of the data validation instead of the relative data validation. So I want $D$5 to be $D$6, $D$7 etc. in other cells. I have tried Paste Special > Validation, but it didn't work. Maybe there is a script for this?
Thanks.
Thanks to #doug-glancy comment and to make sure there is an answer for this question, writing a formula as =INDIRECT(D5) does the job.
In my case I set the formula and by drag and drop copying the cell formulas of new cells will automatically get updated.
I'm trying to format a single cell within a worksheet, so that it is highlighted if a postcode contained within a long list of postcodes is entered. The cell I'm trying to conditionally format is E26, and the list of postcodes is A63:A2559, and the postcodes are all entered without a space (e.g. SW1A0AA). I've tried a number of ways and formulas to conditionally format the cell (=MATCH, etc), but I keep getting error messages, or it just doesn't format the cell. Is anyone able to help me with a formula?
Thanks in advance
I just tested this formula, if I understand your requirements correctly, it works.
=NOT(ISERROR(MATCH($E$26,$A$63:$A$2559,0)))
My picture below uses different ranges, but just you so how I laid the data - to mimic what I understood as your data set. If it's different, let me know.
E6 passes the test, F6 does not.
i read some tutorials that help out with conditional (or dynamic) data validation, but its usually dynamically generating list item choices based on previous selection etc.
what i want is, lets say i have
columnA : columnB
telephone_number : 911
name: peterparker
is it possible for me to dynamically specify data validation rules on columnB based on what is selected in columnA? if its telephone_number, i want to check that the corresponding cell in columnB is a natural number, and if it is a name,i want to check for a string for a certain length. of course i limit the string options that the user can input in columnA.
Following formula on custom validation rules will do:
=IF(A1="telephone_number";ISNUMBER(B1);IF(A1="name";LEN(B1)=8;TRUE))
This is example for cell in B1. You may choose a wider range and combine $ to adapt you formula to all range.
An alternative to data validation is Conditional Formatting. The benefit of the latter is that it is more versatile. We can have the following setting:
Then if we define a name, DynamicValidation as follows:
the formula at the validation box is
=EVALUATE(SUBSTITUTE(VLOOKUP(Sheet1!$A2,Sheet1!$D$2:$E$3,2,0),"()","("&ADDRESS(ROW(),2)&")"))
EVALUATE cannot be used in any sheet cell, but it can be used in Named ranges. However, you will have to save your book as macro-enabled, because it is a legacy macro, originating from Excel 4.0. What it does is the following:
Looks at the value in List1 and finds the formula that needs to be checked (VLOOKUP).
Subtitutes "()" with the cell value of interest (and adds back the parentheses).
Then if you open a conditional formatting box (Home tab, Conditional Formatting, New Rule, Use a formula to determine....) and input the formula =Not(DynamicValidation) like this:
then each cell that does not adhere to the formula will turn red. I tried that with data validation as well, but it does not work unless we build the depencency tree every time we change List 2.. I am not sure why.. But only conditional formatting works :) Here are some screenshots:
The benefit is that we can change the validation criteria without hard-coding.
I hope this helps!
I have to restrict some invalid data in a Excel Column.
Below is Validation Criteria:
Should be a numeric Number
Size/Length should be equals to 9
Ex : valid:602005514, invalid:were,43456 etc.
I have created a Custom Data Validation using below function.
=AND(LEN(INDIRECT(SUBSTITUTE(ADDRESS(ROW(),COLUMN()),"$","")))=9,
ISNUMBER(INDIRECT(SUBSTITUTE(ADDRESS(ROW(),COLUMN()),"$",""))))
//here i have to get cell name dynamically. so, i have used ADDRESS function
But its not working as expected. It is not allowing any value in cell.
I guess it might be because of LEN function circular reference.
I have tried many ways, but not able to solve it. Please help me to solve this.
You don't need to resort to INDIRECT etc, in you formula just refer to top left cell in the range you are applying the validation.to. Excel will adjust for the othger cells in the range. When entering cell references don't use absolute references, ie no $'s
Eg select a range starting at cell A1, and set data validation formula to
=AND(ISNUMBER(A1),LEN(A1)=9)
Check this simple validation .. checking Cell D13 ..
=IF(LEN(D13)=9,IF(ISNUMBER(D13),"yes","no"),"no")
Another way:
=AND(ISNUMBER(A1),A1>99999999)
Make sure there are no leading or trailing spaces in the cell:
=IF(TRIM(A3)=A3,TRUE,FALSE)