Set countif / countifs range to ONLY the last row in a range - excel

I am trying to find the number of times a certain text string appears on the last inspection of a vehicle. The columns are areas to check, and each inspection is on a separate row. The range is D6:VG150 (the 150 is to allow for future inspections). The majority of cells are blank, either because I haven't used that row yet, or there was no fault found in that area during a previous inspection. The only column that will be filled is column A, which has the dates of inspection. I ONLY want results from the last inspection (to indicate current status on a fleet status worksheet). Even better would be to check the last filled cell in every column in that range, but that might be pushing it.
I have tried =COUNTIF(INDIRECT("'291'!$D$6:$VG"&INDEX(MAX((A:A<>"")*(ROW(A:A))),1)),"Schedule Repair"), but it returned the results from the entire range defined by the last range. I tried switching the first address of the range, $D$6, to $D&, but this returned a #REF! error.

I've tried to simplify your scenario. The screenshot below shows a table that starts in row 3 and extends to row 7. The formula counts how many cells in the last row of the table have the text "a". The formula is
=COUNTIF(INDEX(A:A,COUNTA(A:A)+2):INDEX(C:C,COUNTA(A:A)+2),"a")
You don't need Indirec. Index is a lot better. The first Index returns the cell A7. The second Index returns the cell C7. Using the colon as the operator will turn the two cells into a range that can then be used by Countif.
The last row is identified by counting all cells with text in column A, and then adjusting for the fact that there are empty rows above the table.
Oh, and by the way, if you use an Excel Table, you don't need to pre-fill formulas into empty rows. In an Excel Table all formulas are automatically applied to new rows.

Related

Excel formula to find last non blank cell in a column starting on a certain row

So I've got a column of data that I want to count the non blank cells after a certain row.
Here's an example of what I have:
So, in this example, I would like to start counting non blank cells in column A starting on row 13 (which would be a total of 4). If you look at the formula I have entered into cell D12 I can get the value I'm looking for with this formula:
=COUNTA(A:A)-11
I could use this formula:
=COUNTA(A13:A16)
but the point is the last cell with data in it can change due to entering different amounts of data in the column.
But I'm wondering if there is a different formula I could use that would count non blank cells from a certain row down regardless of the amount of data I enter into the column from a certain row down using an open ended range, kind of like this:
=COUNTA(A13:A)
This formula doesn't work but it kind of illustrates what I tried to do that didn't work.
from my comment above:
Well, you could always get the last used row dynamically and incorporate that, not sure what your benefit is over using the last row:
=COUNTA(A13:INDEX(A:A,LOOKUP(2,1/(A:A<>""),ROW(A:A))))
This makes it somewhat "open" ended I guess. Unfortunately it isn't GS =)

Second to last non blank cell without Array Formula (Excel Online)

I have an Excel Online sheet that has info coming in from a Microsoft Form. I need to find the highest non blank cell and the second non blank based on one criteria. The last non blank was easy with LOOKUP
=LOOKUP(2,1/(K2:K1000="6"),G2:G1000)
However it is proving difficult to get the penultimate non blank cell without using Array formulas. Excel Online doesn't update Arrays automatically, you have to CSE each cell which is not too timely with my number of cells. Is there a non array way of getting the second to last non blank cell contents?
I have spent a long time searching and only found ARRAY solutions or ways of getting the penultimate cell when its a number. Unfortunately my entries are text. Cheers.
As long as you can start at row 1 because row 1 are headers and so K1 cannot be 6 it could be:
=INDEX(G1:G1000,LARGE(INDEX((K1:K1000="6")*ROW(K1:K1000),0),2))
LARGE(...,2) points to second last cell fulfilling criterion in column K.
Else it must be more complex:
=INDEX(G2:G1000,LARGE(INDEX((K2:K1000="6")*(ROW(K2:K1000)-ROW(K1)),0),2))

Find the last not empty column in a range where cells may contain a formula

I have a spreadsheet that acts as a drawing register.
The first 5 columns make up the drawing name/number. I place the revision number of the drawing in each subsequent column. Some of these columns appear blank, but have formulas for other functions in the worksheet.
I would like the first column after the drawing name/number (col F in this case) to display the latest revision number.
Essentially this means I need a formula (or VBA code) to search for the last non-empty cell in a row, but ignoring cells that have formulas in them (that appear blank).
Find the last not empty row in a range of cells holding a formula is very similar but refers to the last row in a column (I am looking for the last column in a row). I couldnt adapt it. I think my syntax was incorrect.
To mention a few extra points:
The revisions are alphanumeric
The revisions are in pairs (as each drawing has a status code and revision, both of which are alphanumeric) and in the first 2 columns (F and G) I need to show the latest status and revision respectively. The status and revision are placed in adjacent columns on the same row each time. So in reality I need a formula that will return the last 2 non-empty columns and the formula needs to ignore cells that contain formulas that return a blank value.
I have tried various combinations of Lookup (similar to Ron's response below), index and VBA code as shown in the above link. If possible I would like to keep it as a formula but I am not adverse to using VBA.
The formula only needs to apply to an individual row, but needs to be copied down as each separate drawing is on a new row.
If the revision number might be either text or numeric, you can try:
=LOOKUP(2,1/(LEN($G5:$XFD5)>0),$G5:$XFD5)
Please try (in F1 and copied down to suit):
=INDEX(G1:Z1,MATCH(1E+100,G1:Z1))
Z may be increased if you expect to require more columns.
Formulae that return blanks should be ignored by the above.

Conditional formatting for multiple rows (highlight lowest value in each)

I have a table in a sheet in Excel with over 2000 rows and about 500 columns of data (numbers). Values in a particular column header are being compared to each row underneath that header, and I am using a VBA function to calculate these values (in other words, I am comparing the value in B1 to the values in A2 through A2146, the value in C1 to the same range, etc). I want to highlight the lowest number in each row by filling the cell. I have researched this issue and tried to solve the problem by implementing this solution, but by using MIN instead of MAX:
=A1=MIN($A1:$TX1)
Columns A through TX contain data.
However, when I use this function as a formatting rule, Excel highlights the wrong values and sometimes multiple values in a row. For example, I have a row with a cell containing the value 10.2, which is the only cell highlighted in this row, even though it is neither the MIN nor MAX of the specified row. Additionally, I have another row which contains values 10.6, 8.4, 5.2, and 20.8. Each one of these values is highlighted based on the formatting rule above, though 5.2 is the obvious MIN; the other three cells with the aforementioned values, then, should not be formatted.
How can I remedy this? I have tried adjusting relative/absolute cell references to determine if this could be the problem, but I am quite sure that the way I'm referencing the cells is correct.
Courtesy #barry houdini (copied from a Comment):
Select the whole range of numbers B2:TX2146 (you can do that by typing that range in the box above A1 then press RETURN). Now set CF with the formula that applies to top left cell, i.e. =B2=MIN($B2:$TX2)

Excel: Dynamic Range excluding data/rows based on blanks in specific column

Is there a way to remove from a dynamically generated range full rows based on whether there are blank cells on a specific column within the data that generates that dynamic range?
For example, from the data shown in below table:
I would need the data in the dynamic range to have only the below highlighted data/rows:
The newly created dynamic range would be used in a pivot table and I would like to it to group the dates (therefore the need to remove the blank rows within the range). Please also note that the original list will be updated regularly and would expand (vertically).
You can use the following:
=IFERROR(INDEX($B$2:$C$9,SMALL(IF($C$2:$C$9<>"",ROW($C$2:$C$9),9999999),ROW(A1))-1,COLUMN(A1)),"")
Array Formula Ctrl+Shift+Enter instead of just Enter and drag it in the same row and down
The formula checks if any value in the row is empty (Name or Birthday) to skip the row and look down it
Small will find the smallest row, Row(A1) will change to Row(A2) when drag it down
Column(A1) to copy the first column will become Column(B1) when you drag in the same row
Change B2:B9, C2:C9 and B2:C9 to correspond your Data(last row) and keep $ for fixed references

Resources