I'm working on a spreadsheet and trying to create a formula to count the last cell with data, then return the column heading for that cell.
There are two parts here:
- Find the first cell with data, return the column heading
- Find the last cell with data, return the column heading
I've solved for 1 by the following:
=INDIRECT(ADDRESS(1,COLUMN((INDEX(H223:S223,MATCH(TRUE,INDEX((H223:S223<>0),0),0))))))
But I haven't been able to solve for the second part. I found the following solutions online, but they aren't quite right...
=(ADDRESS(ROW(H223:S223)+ROWS(H223:S223)-1,COLUMN(H223:S223)+COLUMNS(H223:S223)-1))
^ Returns the last cell reference of the range, does not check if cell has data or not.
=LOOKUP(2,1/(H228:S228<>""),H228:S228)
^This one is a bit more promising. This formula returns the value of the last cell with data in the range. But I can't get LOOKUP to work with INDIRECT/ADDRESS/COLUMN functions which I used for the first formula.
Can anyone help me out? Thanks!
FYI - the column headings are months and cells are $ projections. These formulas are supposed to help me understand how $ flows by month for the next fiscal year.