Excel Custom Data Validation - excel

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)

Related

Excel data validation for Alphanumeric and Special characters

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!

REF Error when using INDIRECT function to create dynamic row reference

I have a matrix grid in "MasterSheetGrid". I have separate sheets that divide this info into certain dimensions, making it easier to handle for the user.
In order to make the file dynamic, i am trying to use INDIRECT Function within a function, to locate which row of the MasterSheetGrid to look for the information before returning.
The formula works when i specify the row manually, but using INDIRECT i receive a REF error, even though nothing is deleted.
Manual Formula =INDEX(MasterSheetGrid!$5:$5,MATCH((XLOOKUP($J6,$5:$5,6:6)),MasterSheetGrid!6:6,0))
Formula to locate the row
=(MATCH($C6,MasterSheetGrid!$C:$C,0))
Attempt to merge both using INDIRECT by referencing the cell where the above formula is stored, which results in REF
INDEX(MasterSheetGrid!$5:$5,MATCH((XLOOKUP($J6,$5:$5,6:6)),(INDIRECT(J2:J2,0))))
Ideally i would like to not have to use a cell to store the lookup row formula in, but i thought if i could create a correct formula with the cell reference, i could repeat for the formula.
Does anyone know what i am doing wrong?
This is the view of the user. The formula would sit within column K
This is the MasterSheetGrid view
Instead of using INDIRECT which would cause recalculation at any change in the file, I recommend using INDEX instead. You refer to a fixed sheet name, therefore no need to use INDIRECT.
=INDEX(MasterSheetGrid!$5:$5,MATCH((XLOOKUP($J6,$5:$5,6:6)),INDEX(MasterSheetGrid!$1:$50,J2,),0))
Would be the equivalent of what you tried.
Proper use of INDIRECT would be:
=INDEX(MasterSheetGrid!$5:$5,MATCH((XLOOKUP($J6,$5:$5,6:6)),INDIRECT("MasterSheetGrid!"&J2&":"&J2),0))
And it's good practice to take the following into account (thanks David Leal):
If the Sheet name you're referring to contains one or more spaces you need to wrap the name in ' like 'Sheet name'!
To refer a range using INDIRECT you can use the following syntax (as a string delimited, for example delimited by "):
=INDIRECT("J2:J10")
for a cell, this works:
=INDIRECT(J2)
but if you try the same for a range:
=INDIRECT(J2:J10) -> #REF!
you get #REF!
If you are going to refer a Sheet from your Worksheet, then you need in all cases to enter the input argument as string:
=INDIRECT("Sheet1!A1:A10")
=INDIRECT("Sheet1!A1")
=INDIRECT("'Sheet 1'!A2") -> When Sheet Name has spaces use (') delimiter
Notes: By the way you are invoking INDIRECT using the second input argument (a1) which is optional with the value 0. It is not required for getting a referring a range as I showed before.
I suspect this is the issue you are having

Finding a range and then implementing it in another formula

I am trying to use a variable range based on a pre-defined criteria. In my case I would like to find the range of the “AUD” cells in the table. I managed to get the beginning of the range thanks to:
=ADDRESS(1;MATCH("AUD";1:1;0))
And then I found the end of the range using a slightly modified above formula:
=ADDRESS(1;(MATCH("AUD";1:1;0)+(COUNTIF(1:1;"AUD"))-1))
Then I simply combined the results with the following formula:
=(B4&":"&C4)
And the achieved result was:
$B$1:$D$1
However, I am having difficulties implementing this result inside formulas in which range must be defined, which brings me to my following questions:
Is such kind of implementation possible in EXCEL, I suspect that the result is considered as a simple text and not actually a cell reference? Is there a way I can change that?
One step further, if we trim (for example from $B$1 to just $B) can we still make the formula working?
Due to the fact that to save space I will probably write all the above formulas inside one formula and I expect this formula to become huge, would it be possible to create a VBA public function which can store the range in a variable and then just refer this variable to the formula - for example, SUMIF("=audRefCell()";"AUD";2:2).
I would like to thank you in advance for the help!

Data validation gives error normal cell doesnt

I have this formula
=OFFSET(Products[[#Headers];[Merk]];
MATCH(A2;Producten!$A:$A;0)-1;1;COUNTIF(Producten!$A:$A;A2);1)
It works fine in a normal cell. But as soon as I putt it in the Data Validation>List I get the error.
There is a problem with this formula.
Not trying to type a formula?
Does anybody know what the problem is?
Suggest to change the reference to the Table for the cell address (e.g. assuming the table starts at B6 and Merk is the 1st field then change Products[[#Headers];[Merk]] for B6).
Not all formulas that are valid for Cells are accepted by DataValidation, particularly when they refer to a ListObject for example the formula COUNTA(Products[Merk])is valid in a Cell but not accepted by DataValidation
Formula should be:
=OFFSET(B6;
MATCH(A2;Producten!$A:$A;0)-1;1;COUNTIF(Producten!$A:$A;A2);1)
When referring to a table in a validation formula you cannot refer directly to a table and must use intermediate names.
For example, define a name like this:
_name_Product that is equal to: ="Products[[#Headers];[Merk]"
Then use INDIRECT in the formula:
INDIRECT(_name_Product)
or use entries like INDIRECT("Products[[#Headers];[Merk]")
Hope this helps.

Excel - How to use the value of a cell as the row value of another cell?

Here is my problem:
I have a cell (V4) containing the value 444. I want to use this value in the formula of another cell (M12) in the following way. I want the formula to be equivalent to =MIN(L12:L444) but instead of 444 I want to refer to cell V4 which contains the value 444. But when I type in =MIN(L12:L(V4)) it obviously doesnt work so how do I do it? Sorry if I didn't explain it very well. :S
Would this work for you:
=MIN(L12:INDIRECT("L"&$V$4))
From: Excel - INDIRECT and Using the value in a cell as a cell reference in a formula?
INDIRECT will work and is closest to the solution you described, but I prefer OFFSET, which uses proper references. (For example, if you insert a column in the sheet before L, INDIRECT will break while OFFSET will just update its reference as expected.
Two ways to go with OFFSET:
1 - Start at L$1 and go down $V$4-1 rows. (This will work with $V$4 as you've defined it now.)
=MIN(L12:OFFSET(L$1,$V$4-1,0))
2 - In $V$4, provide the height of the range you want.
=MIN(OFFSET(L12,0,0,$V$4,0))
It's hard to make suggestions without more context, but I'm sure you can tweak one of these patterns to meet your needs.
I am not sure if you are trying to include all of the values in 1 column and then on non-contiguous cell. If so, it should look like = Min(L12:L444,V4) . The L12:L444 looks at the value in every cell in the L column from 12 - 444.
So you can check individual cell (A3, D15, Q54) with commas, or a range of cells (A3:Z54) with a colon. Or a range and a specific cell like above =Min(L12:L444, V4).

Resources