Data validation gives error normal cell doesnt - excel

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.

Related

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

Excel Offset formula in a cell by itself

This phrase is embedded in many formulas on my sheet:
OFFSET(Table1[ReportDate],0,$B$1)
It returns a reference to a column in Table1.
To make those many formulas shorter, I'd like to extract this OFFSET formula to a separate cell for the others to refer to.
The OFFSET returns a reference. Putting OFFSET(…) in a cell just returns #VALUE, and so does INDIRECT(OFFSET(…)).
EDIT: The "many formulas" are SUMIFS, and the OFFSET chooses the column to be summed:
=SUMIFS(OFFSET(Table1[ReportDate],0,$B$1),Table1[ColumnB],$H10,Table1[Report Date],"<="&rYesterday)
If I understand you correctly, you want to replace the original OFFSET formula with something simpler to be used in other formulas.
You can do so by giving a name to this OFFSET formula.
In the above mock-up example, I have given a name SUM_Rng for the OFFSET formula and used it in my second formula, which is the same as your original SUMIFS formula.
You can press Ctrl+F3 to bring out the Name Manager in Excel and add or modify names which can represent a reference of a cell or a range either hard-coded or returned by a formula. I noticed that you already used a name rYesterday in your SUMIFS formula so there should be no problem for you to add this formula to the name manager.
Cheers :)

Excel - Self reference a cell in conditional formatting

I am trying to create a conditional format formula to colour a cell based on the value of itself, the cell next to it on the right, and whether the cell on the first row in the same column is a weekday or not.
Currently it works correctly as follows:
=AND($A$2=0,$B$2=0,WEEKDAY($A$1)<>1,WEEKDAY($A$1)<>7)
I have a lot of cells I'd like to use this formula in, so I thought about creating a cover-all formula that used the ADDRESS function.
My original idea was to use:
=AND((ADDRESS(ROW(), COLUMN()))=0,$B$2=0,WEEKDAY($A$1)<>1,WEEKDAY($A$1)<>7)
(I've changed just one cell reference here for example, but I'd like to change all 4 if possible).
However, when I try to use ADDRESS(ROW(), COLUMN()) in place of an absolute cell reference, the formula doesn't format the cell anymore.
Is there a way to make this cover-all formula work so that I don't have to go through and change the referenced cell values each time for every cell? Am I missing something about the syntax? Or will this simply not work the way I'd like it to? Thanks in advance!
ADDRESS returns a string that looks like a cell address and "$A$2"<>0.Wrap the ADDRESS in INDIRECT or rewrite your original without absolute rows.
=AND(indirect(ADDRESS(ROW(), COLUMN()))=0, indirect(ADDRESS(ROW(), COLUMN()+1))=0, WEEKDAY($A$1)<>1, WEEKDAY($A$1)<>7)
=AND($A2=0, $B2=0, WEEKDAY($A$1, 2)<6)

Display the value from the formula ONLY if another cell has the value that I want

I've devised a formula that I want my cells to have, but I only want the value to show up if ANOTHER cell is populated with the value that I want.
My current formula is below:
=COUNTIFS($R$3:R21, "Brain")
However, this formula doesn't check whether or not the other cell has the value that I want to check for.
I put together a formula that I thought would check for whether or not the cell is populated:
=COUNTIFS($R$3:R21, "Brain", R21, "Brain")
Unfortunately, this formula doesn't work (it returns #VALUE!). I think it fails because R21 is already included in the COUNTIFS.
I also tried this similar formula, which also failed to work:
=COUNTIFS($R$3:R21, "Brain", R21:R21, "Brain")
I looked online and I found this possible solution:
=IF(ISNUMBER(SEARCH("Brain",R21)),"COUNTIFS($R$3:R21, 'Brain')","")
Unfortunately, this formula displays the text of the formula I want, and not the actual value of the formula.
Does anyone know how I could display the value from the formula ONLY if the cell I'm checking has the value that I want? Thanks.
Try
=IF(ISNUMBER(SEARCH("Brain",R21)),COUNTIFS($R$3:R21, 'Brain'),"")

Excel Custom Data Validation

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)

Resources