I have a COUNTIF formula that counts a particular value across a range of columns in each row. However, I would like to exclude the cell values in a particular column based on the column header.
For example, I need to count the number of cells that contain the value 'NS' across a range 'C:Z' for each row in the worksheet. However, I need to exclude the values in cells that have a column header 'RC'. The challenge is, I cannot control where these 'RC' columns appear in the range. Therefore, I am looking for some mechanism through which I can check whether the column header is 'RC' or not, and if it is, then exclude the cell values from the COUNTIF formula.
Is there anyway to do this?
Use COUNTIFS:
=COUNTIFS(C$1:Z$1,"<>RC",C3:Z3,"NS")
EDIT:
As noted by #JvdV, if you are just looking for a single formula to count all instances (i.e. not row-by-row), you can use =SUMPRODUCT((C1:Z1<>"RC")*(C2:Z100="NS")), changing the 100 to your last row as necessary.
Related
My SUMIFS formula criteria is based on a cell (say A1) that is data validated by list and changed via selection by user. If cell has data inside text or number by selection from drop down list, SUMIFS formula is considering that data as criteria to calculate the related sum. If criteria cell is left blank, I want formula to sum everything without any condition. My problem here; in criteria field of SUMIFS formula, I typed if condition like; SUMIFS(sum-range,criteria_range,IF(A1<>"",A1,"*")) but in this case excel considers only text values and do not include cells containing number. Briefly, if nothing selected in A1, I want SUMIFS formula to sum everything without any condition, numbers, texts and even blank cells. How can we proceed to do that?
EDIT:
Here an example for data and formula, what is expected is actually to disable criteria if one of selection is blank on left. Harun's suggestion works but if there is blank cell in criteria range, then in this case it won't consider those values in sum. For instance, if we select from left Phone/smart/touch, then how can we get "2" as output no matter what is in cri_range4 cells? Thanks
Example:
How about this solution? It basically ignores a missing entry in column C and evaluates only the other two. (Your example formula has a fourth criterium that isn't apparent in your list but the method can be extended for as many criteria as you might have.
=SUMPRODUCT((IF(LEN(C2),(INDEX(Lists,,1)=C2),TRUE))*(IF(LEN(C3),(INDEX(Lists,,2)=C3),TRUE))*(IF(LEN(C4),(INDEX(Lists,,3)=C4),TRUE))*SumRange)
For better readability I created a named range Lists which comprises your sample range E2:H10 while I named I2:I10 as SumRange'. INDEX(Lists,,1}` refers to the first column of the range. It's important that SumRange and Lists have the same number of rows.
If A1 is blank then just use not equal operator to sum all cells that are not blank. Try below.
=SUMIFS(D1:D5,C1:C5,IF(A1<>"",A1,"<>"))
Edit: can you check below formula in D3 cell then drag down.
=IF(C2="",SUM($I$2:$I$10),SUMPRODUCT(($E$2:$H$10=C2)*($I$2:$I$10)))
I have an excel sheet when I am trying to use SUMIF to add values based on the values of another range as below screenshot:
I am using the below SUMIF formula:
=SUMIF(B2:B560,"<=10000",A2:A560)
My target is to have the sum of cells in column A if their corresponding value in column B is less than or equal 10,000.
My issue is that excel ignores the blank cells while I need them to be counted as less than 10,000. I can't manually replace blank cells because it is a long sheet.
I appreciate your time and support.
One option is an additional SUMIF:
=SUMIF(B2:B560,"<=10000",A2:A560)+SUMIF(B2:B5260,"",A2:A560)
Another option is SUMPRODUCT:
=SUMPRODUCT(A2:A560*(B2:B560<=10000))
A third option, if you have access to the FILTER function:
=SUM(FILTER(A2:A560,B2:B560<=10000))
Sheet One has 5 cells in a row with numbers. (A2:F2)
Sheet Two also has 5 cells in a row with numbers. (A3:F3)
I'd like to highlight sheet one's cells yellow every time that sheet two has a matching number entered. (There will be more rows of data added to each sheet, but I am using the first row only, to keep it simple.
It works with creating a CF equals to, but I need something that applies to a range of data, from a range of data to make this less tedious. Thank you for any tips!
I am using conditional formatting. I have tried Vlookup, Match, and Countif, but I am new to this type of formatting.
(Sheet two's numbers can be placed in a list (column), instead of a row, if that matters)
I'd suggest using COUNTIF:
=COUNTIF(Sheet2!$A:$F,A2)>0
Snapshot of Sheet1 and the Conditional Formatting:
Snapshot of Sheet2:
I am trying to figure out if it is possible to use a formula with conditional formatting or a VBA macro to highlight a cell based on a cell with identical contents in another column, with varying data.
To explain more thoroughly, let's say I have column A, with unique content in each row, rows 1-280. Each row is formatted to be a string of text, such as "12E00" or "97EBC." I also have column T, which is based on imported data, and may contain some of, but not all of, nor in the same row, the data from column A. It also starts at row 9, not row 1. This is repeated on 47 different tabs, with differing row contents on different tabs (some may have 1-280, others may have 1-160).
Is there some conditional formatting formula/macro (with an explanation of the working components of possible, so that I can learn myself and educate my supervision on the inner workings) that would allow me to highlight any of the cells in column A that have the same text string shown somewhere in column T? Additionally, keeping in mind that I'm checking every row in column A against column T and that column T will only contain some of the text strings in column A.
I assume there is a better way to accomplish this.
But if I understood the question correctly, then try using: =ISNUMBER(MATCH(cell,column,0))
I would then make a column next to Column A for each sheet you want to check.
Example table, with a column for each sheet checked, and a column for checking if any sheets matched. Matched cells are highlighted.
47 columns might be too much to, therefore I used Column B to do:
=OR(Table1[#[sheetName]:[otherSheetName]])
Each column have the formula: =ISNUMBER(MATCH([#[Column A]],INDIRECT(C$1&"!T:T"),0)) (C$1 is pointing to the column's header row)
Utilizing INDIRECT() the column will always look in column T in the sheet with the same name as the column header.
The highlighting is done with these conditional formatting rules
Hi I have store numbers in different columns and products in rows with sales for respective stores. I want to do sumif in a different sheet by changing stores and products in data validated cells. How do I select dynamic columns in Sumif based on store numbers. Attaching image for reference.
Here's a mockup based on your sample data, with row numbers and column letters shown:
Using that as a base, in cell C15 is this formula:
=SUMIF($C$3:$C$9,$C$14,INDEX($D$3:$G$9,0,MATCH($C$13,$D$2:$G$2,0)))
You'll need to adjust the ranges to suit your actual data.
=SUMIF(A2:A6,"=Shirts",B2:B6)
A2:A6 - This is the range over which the condition applies
"=Shirts" - the conditional expression.
B2:B6 - The cells under consideration for summing up.