Count non blank rows in a certain range/column Excel - excel

I want to count empty (or non-blank) rows in a given column (or range).
Example: I have a column which is spaning over 4 cells width, and each cell has either a single ''x'' or is empty. There is up to 100 rows under this column. Here's a picture to clarify:

The COUNTA() function will do that for you. For example:
=COUNTA(A1:A100)
Will return the number of non-blank cells in the range A1:A100

You can use array formula. For example, to count the first 10 rows starting from row 2.
=SUM((COUNTBLANK(OFFSET(B2,ROW(1:10)-1,0,1,4))=4)*1)
To count the first 100 rows:
=SUM((COUNTBLANK(OFFSET(B2,ROW(1:100)-1,0,1,4))=4)*1)

Use a new column to get the number of blank cells in each row, then count the number of row in this column which are equal to 4.
Or, more simply, write =QUOTIENT(COUNTBLANK(B2:E2);4) in F2, pull the cell down, then write =SUM(F2:F101) in G2.
If there is exactly 4 blank cell in a row, the F cell will have a value of 1 and the sum will just add all of these 1 to get the number of empty rows.

Related

Test for 2 values in column range until bank cell is reached in different column

I am attempting to test whether two values in a range exists, I am fully aware of how to achieve this, my issue is that the number of rows in the range change and I want to test until the next blank row in column E then continue to the next until another blank row is detected. I have therefore placed a match argument in Column H to count the number of rows until a blank is found.
Column G holds the data I want to argue against which itself is a lookup and therefore the blanks in the rows are not blanks, hence using column E
In column I4:I100 want to write a formula that states If value “C” AND “D” exists in column G for the next 7 rows then enter ‘Y’, then repeat the argument after the 0 in column H, for the next 6 rows and again for the next 2 rows etc etc I have manually entered my desired result in column I highlighted in green.
I hope this makes sense, Many thanks.
Maybe try this in I4 and drag down:
=IF(G3="",IF(AND(COUNTIF(INDEX(G:G,ROW()):INDEX(G:G,MATCH(TRUE,INDEX(INDEX(G:G,ROW()):G$33="",),0)+ROW(G3)),"D")>=1,COUNTIF(INDEX(G:G,ROW()):INDEX(G:G,MATCH(TRUE,INDEX(INDEX(G:G,ROW(G3)):G$33="",),0)=ROW()),"C")>=1),"Y","N"),"")
Now you can remove column H:H

Count unique values in a column with blanks for each row in excel

I have a column of data (shown below) that I want to count each unique value in this list. I used this formula:
SUMPRODUCT((B2:B11540<>"")/COUNTIF(B2:B11540,B2:B11540&""))
However it gives me the entire count of unique ids and I want to count per row. Also, since this column has lot's of blank fields I am not able to count for each row using CountIf. Ideally the blank rows should give 0 and other duplicates should be counted as 1. Does anyone has a way of solving this?
A-2019-000084
A-2019-000141
A-2019-002944
A-2019-000222
A-2019-000222
A-2019-000222
A-2019-000222
A-2019-004606
A-2019-004606
A-2019-000923
A-2019-000699
use COUNTIF with a variable range:
=--AND(A1<>"",COUNTIF($A$1:A1,A1)=1)
For a total unique non-blank count of your sample data in column A use,
=SUMPRODUCT((A2:A23<>"")/(COUNTIFS(A2:A23,A2:A23,A2:A23,"<>")+NOT(SIGN(LEN(A2:A23)))))
For a row-by-row count, (with the first A-2019-000084 in A2) use this in B2 and drag down.
=--(COUNTIFS(A$2:A2, A2, A$2:A2,"<>")=1)

Get row index of most recent non-blank cell in adjacent column (Excel)

In an Excel spreadsheet I have Column A with some text spaced out by blank cells. I want in Column B to return the row index of the nearest non-blank cell in Column A (from above only).
Put this in B1 and fill down.
=match("zzz", a$1:a1)
You could use the following on the second row after manually putting the row number for the first row:
=IF(A2="",B1,ROW(B2))

Excel 2016: adding number values in a row from cells with text and numbers

I need to add number values in a row where cells contain text and numbers; like "P1" or "S7" where I need to add the 1 and 7 into a total column.
I can extract the number values from individual cells using =RIGHT(V3,SEARCH("P",V3))+0, but can't figure out how to do that easily for row of 32 cells.
Example:
For example to sum D1 through G1, use:
=SUMPRODUCT(--MID(D1:G1,2,9999))
As you see, this formula discards the lead text character in each cell.
EDIT#1:
To add cells beginning with P or S only, use:
=SUMPRODUCT(--MID(D1:G1,2,9999)*(LEFT(D1:G1,1)="P")) + SUMPRODUCT(--MID(D1:G1,2,9999)*(LEFT(D1:G1,1)="S"))
You can place your formula on the first column of your row. Then when you copy the formula across your columns it will automatically reference the cell offset the same as V3 is offset from each other cell with formula.

Count number of blank cells in row between last cell and next non-blank cell

Is it possible (with a formula preferably) to count the number of blank cells in row, where the counting starts at a given column and counts going backward (e.g. right to left) the number of blank cells until a non-blank cell is found? In the example below, the counting begins at Column H and proceeds leftward. Using COUNTA or COUNTIF seem like reasonable tools to use, but I am unsure on how to terminate the counting once a non-blank cell is found.
You can use something like this if the values in your table are all text:
=COUNTBLANK(INDIRECT(CHAR(97+MATCH("zzzz",B2:H2))&ROW()&":H"&ROW()))
MATCH("zzzz",B2:H2) returns the column number in which the last non-blank cell is.
CHAR(97+ column number) returns the letter of that column.
Append it to the row number to give the reference where the COUNTBLANK has to start with &ROW()
&":H"&ROW()) gives the reference of the last cell, which is H plus the row number.
INDIRECT turns the concatenated text into a range that Excel can evaluate.
Try this formula
=COLUMNS(B2:H2)-MATCH("zzzz",B2:H2)
You could use nested if statements
=IF(ISBLANK(H2),IF(ISBLANK(G2),IF(ISBLANK(F2),IF(ISBLANK(E2),IF(ISBLANK(D2),IF(ISBLANK(C2),IF(ISBLANK(B2),IF(ISBLANK(A2),8,7),6),5),4),3),2),1),0)

Resources