Newbie-ish with Excel here. I'm trying to keep things simple for long term ease of use since most at my job don't know much of anything with Excel or anything with VBA.
I'm looking to have a formula count cells containing up to 4 different codes (TRM2-TRM5) out of 32 possible codes. However, the cell these combinations are entered in is not required to be in any specific order.
Such as:
B1 (TRM2, R2, TRM3)
B2 (TRM2, PN1, DC5, TRM4)
B3 (PN1, IPA5c, HW2, TRM5)
B4 (PN1, HW2, R2)
The desired result of the formula is a count of 3
I don't need to count the individual number of times the TRM codes appear. Just the number of cells they appear in a range (such as B1:B99).
I've tried COUNTIFS but quickly discovered I'd have to have a COUNTIFS for each possible combination of the 4 codes.
So far the simplest way is to use multiple instances of conditional formatting that highlights the cells that contain one of the four codes and do a visual count. All the examples I've read don't have multiple values in one cell so I'm not sure how to tackle it.
For those that are curious, the purpose is error reporting for issues missed in an audit.
Thanks for the help!
Given your example, you can do this with a helper column.
Either hard code an array constant with the codes to find, or enter them in separate cells someplace. I did the latter and named that range theCodes.
Use this array formula in the helper column:
C1: =MIN(FIND(theCodes,B1&CONCAT(theCodes)))<LEN(B1)
and fill down as far as needed
This will return TRUE or FALSE depending on whether any of the codes are present in the cell.
Then, a simple COUNTIF will count all the TRUE's
D1: =COUNTIF($C:$C,TRUE)
NOTE: To enter/confirm an array formula, hold down ctrl + shift while hitting enter. If you do this correctly, Excel will place braces {...} around the formula seen in the formula bar.
Related
I have a spreadsheet...
A you can see, the cell F2 has a formula with multiple COUNTSIF, basicly checks the cells F14, F33, F62 y there is a Pass there, and if there is one will give you a % completion. My question is that I have to add around 20-30 COUNTIFS to that formula, is there a way to simplify it.
=(COUNTIF(F14,"Pass")+COUNTIF(F33,"Pass")+COUNTIF(F62,"Pass")+COUNTIF(F75,"Pass")+COUNTIF(F88,"Pass")+COUNTIF(F105,"Pass"))/(COUNTIFS(F14,"<>na")+COUNTIFS(F33,"<>na")+COUNTIFS(F62,"<>na")++COUNTIFS(F75,"<>na")++COUNTIFS(F88,"<>na")+COUNTIFS(F105,"<>na"))
This is not the final formula, still missing around 20 entries. If you're wondering why not do a simple F15:FXX, because i just need the cells that have a test case name, like F14, F33, etc.
For the first part of your formula, you can use the INDEX function to return a non-contiguous set of values, which you can test.
For example, the equivalent for the first part would be:
=SUM(N(INDEX($F:$F,IF(1,N({14,33,62,75,88,105})))="Pass"))
The IF(1,N({…})) part is how you specify which cells (rows) in Column F to return.
Without knowing more about your data, not sure about handling the percentage issue.
Your posted formula would not calculate a percentage, as it is only dividing the SUM by whether or not F14<>"na" is true, and then adding one for the <>"na" factor for the rest
In earlier versions of Excel, you may need to confirm this array formula, hold down ctrl + shift while hitting enter. If you do this correctly, Excel will place braces {...} around the formula seen in the formula bar.
If you want to return the percent "pass" in your list of cells, merely divide the SUM by the number of cells. You can either hard-code that number, or compute it with something like:
COLUMNS({14,33,62,75,88,105})
Or all together:
=SUM(N(INDEX($F:$F,IF(1,N({14,33,62,75,88,105})))="Pass"))/6
or
=SUM(N(INDEX($F:$F,IF(1,N({14,33,62,75,88,105})))="Pass"))/COLUMNS({14,33,62,75,88,105})
I'm having a problem writing my formula that should count all selected cells that contain a number bigger than 0 and skip the cells that are completely empty, even when the cell is selected. Excel gives me an error that I selected cells that not contain a number. How can I skip them?
This is my formula:
=COUNTIFS(C8:C12;E8:E12;G8:G12;I8:I12;K8:K12;">0")
I'm thinking you using the COUNTIFS() formula wrong, after each range, there is a criteria. You can't have multiple ranges like that to look through. For more information look here or here.
In your case you are dealing with a non continues range, and one way to deal with that would be this
So the formula would translate to:
=SUM(COUNTIF(INDIRECT({"C8:C12","E8:E12","G8:G12","I8:I12","K8:K12"}),">0"))
Another formula you could try is:
=INDEX(FREQUENCY((C8:C12,E8:E12,G8:G12,I8:I12,K8:K12),0),2)
And looking at your data, it seems as though the rest of the columns contain text (not sure, they may be dates). In case they are text values:
=SUMPRODUCT((ISNUMBER(C8:K12))*(C8:K12>0))
If they are actually dates (assuming from 2018), then you could try:
=SUMPRODUCT((YEAR(C8:K12)<2018)*(C8:K12>0))
I'm assuming this is what you looking for, instead of a VBA based solution due to the tags provided and your formula.
You could also do it in this particular case by skipping the columns that you don't want:
=SUMPRODUCT((C8:I12>0)*ISEVEN(COLUMN(C8:I12)-COLUMN(C8)))
what will be happen if you use the below formula? to you receive an error?
=COUNTIF(C8:C12,">0")+COUNTIF(E8:E12,">0")+COUNTIF(G8:G12,">0")+COUNTIF(I8:I12,">0")+COUNTIF(K8:K12,">0")
Try this
Requirement cannot be done in single formula,
combining 2 or more formula will help fixing the formula.
formula
=COUNTA(B2:B9,D2:D9) -- Count all the non blank cell's
=COUNTIF(B2:B9,"=0")+COUNTIF(D2:D9,"=0") -- Count all the cells will value as 0
Subtract both which will give the output you are looking for
Combined formula
=COUNTA(B2:B9,D2:D9)-(COUNTIF(B2:B9,"=0")+COUNTIF(D2:D9,"=0"))
I am straggling with some formula that I have a spreadsheet that contains two range of cells. What I want to do is,
I would like to create a search Box that will search a value from Range A and if found return range B value and also will count of range B value is repeated.
Below image is for what I mean
I used INDEX, MATCH and also IF Functions :( but not really get what I wanted.
I am poor in formula, so it would be great if someone can figure out what kind of functions I should use for this.
For information, it can be achieved through formula as below.
E3 houses the value being searched for e.g. "A"
In cell F3 insert following array formula which needs to be committed by hitting CTRL+SHIFT+ENTER simultaneously.
=IFERROR(INDEX($B$1:$B$1000,SMALL(IF(IFERROR(MATCH($E$3&$B$1:$B$1000,$A$1:$A$1000&$B$1:$B$1000,0),0)=ROW($B$1:$B$1000),ROW($B$1:$B$1000)),ROWS($A$1:A1))),"")
Copy down as much as you need.
You need to adjust 1000 to suit your data. It should match last row.
In cell G3 you can use following formula.
=IF(F3="","",COUNTIFS(A:A,$E$3,B:B,F3))
Copy down as much as you need.
I am trying to compare the numbers in the Reachability Set column with the numbers in the same row of the Antecedent Set column and return the common values in the corresponding cells of the Intersection Set column.
Screenshot:
In Excel 2016 (but NOT Excel 2013), you can use the following array-entered formula.
=TEXTJOIN(",",TRUE,IFERROR(1/(1/(ISNUMBER(FIND(","&TRIM(MID(SUBSTITUTE(B2,",",REPT(" ",99)),seq_99,99))&",",","&A2&","))))*TRIM(MID(SUBSTITUTE(B2,",",REPT(" ",99)),seq_99,99)),""))
seq_99 is a Named Formula
Refers to: =IF(ROW(INDEX($1:$65535,1,1):INDEX($1:$65535,255,1))=1,1,(ROW(INDEX($1:$65535,1,1):INDEX($1:$65535,255,1))-1)*99)
To enter an array formula, after entering the formula in the cell, confirm by holding down ctrl + shift while hitting enter. If you do it correctly, Excel will place braces {...} around the formula.
Although you would think a VBA solution is required, it is actually quite simple to do this with formulae, provided you use a lot of helper columns. These can, of course, be hidden.
All you need is a number of columns equivalent to the maximum of the numerals in the sets, after each of the original columns of your table. For the example supplied, this would be 17 columns.
Here is a screenshot of the new table with the helper columns unhidden:
The follow formulae are entered into the top left cell of each coloured region and filled/copy-pasted/ctrl-entered into the rest of the cells.
Red Cells (entered into B2):
=IF(ISERROR(FIND(","&B$1&",",","&$A2&",")),0,1)
Green Cells (entered into T2):
=IF(ISERROR(FIND(","&T$1&",",","&$S2&",")),0,1)
Blue Cells (entered into AL2):
=IF(B2*T2,AL$1&",","")&AM2
And finally, the result entered into cell AK:
=LEFT(AL2,LEN(AL2)-1)
The formulae work by ensuring that all the numbers in the sets have a preceding, and trailing, comma so that they can be uniquely searched for.
Then it is a simple matter of constructing a grid for the sets where a 1 means the number exists in the set a 0 means it doesn't. Multiplying these two grids together results in the "intersection set".
Then it is a simple matter of reconstituting the result strings.
Caveat:
This solution won't work correctly if there are any spaces in the "Set" data. To overcome this you need to use the SUBSTITUTE() function.
I have a table of my workdays and I want to count instances of word 'work' in each row.
I have a table like this:
I used this code in J1 cell but it doesn't work.
=SUM(IF(2:2 = "Sleep",1,0))
I have found this formula in microsoft's website but it doesn't work.
What is causing this problem?
You need to use the COUNTIF function.
=COUNTIF(C2:I2,"Sleep")
This goes in Cell J2
From Excel's Help
The COUNTIF function counts the number of cells within a range that meet a single criterion that you specify. For example, you can count all the cells that start with a certain letter, or you can count all the cells that contain a number that is larger or smaller than a number you specify.
When in doubt, press the magic button F1 in Excel. :)
Just came across a similar thing in a worksheet and came to google before I remembered why it didn't work.
The countif statement above is perfectly fine, however the original formula given wouldn't have worked as to use a sum in this way means you have to make it an array or CSE Formula instead.
So, if you come across this, click in the formula bar and press ctrl + shift + enter and it should sort the whole thing out.