Excel 2010 CountIf function only works with debug - excel

I have the following excel function:
=SUM(COUNTIF($B22:$BA22,$BY$4:$BY$49))
The first range B22 - BA22 is filled with formulas that read data from other spreadsheets.
The values displayed in those cells are like "1234Pass", "3456Fail".
The values in the second range, BY4 - BY49, contain all of the possible Fail values. Those are typed in manually. All Cells are formatted as general.
The SUM formula above always displays 0 in the cell. However if I click in the formula bar and press F9, the correct value is displayed.
What am I doing wrong?

Enter the formula as an array formula -- hold down ctrl+shift while you hit enter. Excel will put braces {...} around the formula if you do it correctly

Related

Excel - Highlight cell which is closer and smaller to a specific value

I would like to highlight a cell which is the closest the a specific value but still lower (below) or equal according to a formula.
For instance, if I have 14 in B4, I would like the cell 13 (or 14) highlighted but not 15 in the range.
The value I need to look for would be in B4 and the range that I must apply the highlight formula to would be L1:L371.
So far, the best result I was able to achieve was with (from what I was able to find using Google or Stackoverflow already existing content):
=SMALL($L1:$L317,COUNTIF($L1:$L371,"<="&$B$4))
Although, not only it selects the value I am looking for, it also selects all the values below.
May someone provide me some help so I can achieve the expected result please?
Thank you for your time and help, it is greatly appreciated.
Based on your description, it seems like you need to find the maximum value of a range (L1:L137) that is less than or equal to an input variable (B4) and highlight that value in the search range. Depending on what version of Excel you have, here's what you need to do:
For Excel 2019 or Excel 365
You can use the MAXIFS function. You would actually put that function in a conditional formatting rule, but more on that in just a second. As a test, put the following code in cell B5:
=MAXIFS($L$1:$L$137,$L$1:$L$137,"<="&$B$4)
The first argument is your "MAX_RANGE", or the range that contains the values you want to find the max of. It is also our "CRITERIA_RANGE", the second argument. The third argument is the criteria itself, which is that the search range must be less than or equal to the value in cell B4. Essentially, we are going through the list and creating a subset of numbers that are less than or equal to our search value, and discarding the rest. I assume you are aware of relative vs. absolute referencing, since you used the "$" anchor in your referenced code. If not, here's a description of the difference.
Now, the result of that formula should be the highest number in the list less than or equal to the search value, but that doesn't highlight it for us in our list. To do this we need conditional formatting. To do this, highlight your data range (L1:L137) and go to the conditional formatting drop down on the home tab of the menu ribbon. Choose "New Rule". On the dialog that pops up, choose, "Use a formula to determine which cells to format". In the formula input box, enter:
=L1=MAXIFS($L$1:$L$137,$L$1:$L$137,"<="&$B$4)
This will compare whether the value in the cell being evaluated (L1, for instance) is equal to the result of that formula we talked about above. Since L1 is only relatively referenced, this formula will work for every cell in the data range.
Now, before you hit "OK" on the dialog, select the Format button. This will allow you to adjust your highlighting and formatting as you desire. Click "OK" on the formatting dialog, then "OK" on the Conditional Formatting Rule dialog. This should now highlight any data cell that is equal specifically to the result of our formula, and not everything that's less than our value.
For Earlier Versions of Excel
The concept is the same in earlier versions of Excel, but unfortunately, the MAXIFS function is not present in these versions. Instead, we must use an array formula. Array formulas are a whole other can of worms, but ExcelJet is an excellent resource. In fact, they talk about this very issue, here.
Unfortunately, we can't put the array formula in the conditional formatting formula like we did above, so we'll need to put this formula on a cell in the worksheet, then the conditional formula should reference that new cell. So in cell B5, if you put:
=MAX(IF(L1:L137=B4,L1:L137)
And then, instead of pressing Enter, you must press Ctl + Shift + Enter
This keyboard combination will tell Excel that you are trying to enter an array formula. If you don't press these keys, then the formula will error. Once you have entered the array formula, if you put your cursor in cell B5, you will see the formula bar at the top has added curly braces ({ , }) around the formula to look like
{=MAX(IF(L1:L137=B4,L1:L137)}
This leads to the same result as above, but is just achieved slightly differently. Now, following the same process described above for conditional formatting, you will simply set the formula to:
=L1=$B$5
And that should be it! Hope this helps!

EXCEL - #VALUE on INDIRECT

I'm getting a #VALUE error on an INDIRECT() and can't figure out why. I've never used this function before, so I'd appreciate some pointers.
I'm constructing a string in a cell. The constructed string has a value of the form [items.xls]items!$A$1:$F$30.
For purposes of this question, suppose the constructed string is in cell $A$1 of Sheet1 in workbook1.xls. in cell $B$1, I have =INDIRECT(A1), which I'd hoped would create the actual reference constructed using cell $A$1 so I could use the reference in a VLOOKUP(), but I can't get that far because of the #VALUE error.
I have the workbook items.xls open in excel at the same time as workbook1.xls.
the spreadsheet items exists in workbook1.
what am I doing wrong ?
Because your reference in cell $A$1 is to a range of cells (and not just one cell), you need enter your =Indirect(A1) formula as an array formula.
Select range Sheet1!$B$1:$G$30. 30 rows, 6 columns; the same size as [items.xls]items!$A$1:$F$30.
Type your formula =INDIRECT(A1) into the formula bar. Instead of pressing Enter, press Ctrl+Shift+Enter to complete your formula.
The formula should look like {=INDIRECT(A1)} in the cell.
Check that none of the cells in range [items.xls]items!$A$1:$F$30 has a #VALUE error. If they do, that error will show on your new sheet as well.
Also double-check your formula that constructs the string in cell A1. If part of that formula is returning a #VALUE error, it will pass it on to the INDIRECT() formula.
You can highlight parts of your formula in the formula bar and press F9 to evaluate just that part of the formula. Just remember to hit ESC to exit the cell afterward.
Another alternative is the Evaluate Formula option on the Formulas part of the Excel ribbon menu.

How to declare a two-dimensional array by one cell formula?

In Excel it is pretty simple, for example
={1,2,3,4;5,6,7,8} gives us 2 rows in 4 columns.
But when I try similar in Google Spreadsheet, it fails.
EDIT: See comments below where the language version issue was revealed.
Nearly the same syntax, but different entry methods:
Excel
Hi-light a block of cells and array enter:
={1,2,3,4,5,6,7,8}
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key. If this is done correctly, the formula will appear with curly braces around it in the Formula Bar.
Google Sheets
Select a single cell and enter:
={1,2,3,4,5,6,7,8}
and the extension to the other cells occurs automatically:
Same is true for 2-D arrays:
If you are using Google Sheets, remember to leave enough empty cells to the right and below to hold the result.

An excel formula that returns from text an excel formula

In my spreadsheet I have certain formulas that give as output texts of the form: A1+B3+D9.
These are cell references, the cell rows and columns are calculated automatically within the original formula.
I would like this to be a formula that then gets evaluated. At present I simply copy-special paste as value and then by hand put an = at the front.
Is there an excel command that does this automatically? i.e. takes a text input, interprets the input as an excel formula and hence evaluates it accordingly.
Can you tweak the formula to get something like
=Indirect(A1) + Indirect(B3) + Indirect(D9)
otherwise, there is no way to get it without VBA.

Formula Result in Function Argument Window Different Than in Cell

I have the following array formula:
=MAX(COUNTIF(Sheet2!A$2:Sheet2!A$6,Sheet2!A2:Sheet2!A6))
Which is supposed to give me the count of duplicate entries in a small text column in a worksheet. I've put one duplicate entry to test the formula, and the result I should get is 2. Instead, once I ctrl+enter, the cell shows 0. However, when I click the formula button next to the cell content field, it shows Formula result = 2.
Calculation Options are set to Automatic (this is Excel 2010), and I have no idea why this is happening. Any ideas? Thanks.
Seems it was a keyboard problem with the shift or ctrl buttons stuck (: I clicked on the formula inside the formula argument window, then clicked ctrl+shift+enter and it added the curly brackets for the array formula and the result is now correct and updates correctly when the source data changes.

Resources