(sample Workbook attached)
I've written a function to take an input range, and output that same data with an added column containing the COUNTIF of the values in the first column.
=LET(inputRange,B1:D16,LET(key, CHOOSECOLS(inputRange,1),HSTACK(inputRange, COUNTIF(key, CHOOSECOLS(key,1)))))
The COUNTIF column ends up filled with #VALUE! errors, but the original input range prints out just fine. When I walk through the Evaluate Formula steps it looks like the inputRange is #N/A-ing out (but only in the evaluator - adding an IF(ISNA(inputrange) into my function doesn't trigger), but that appears to cause the COUNTIF data (which somehow still evaluates despite the #N/A's???) to collapse into a #VALUE! error. I don't know why it's happening or how to fix it.
Breaking out only the HSTACK by itself and manually inputting the ranges the LET statements would generate correctly outputs what I want, but I don't know why it suddenly fails inside the LET statements.
=HSTACK(B1:D16, COUNTIF(B1:D16,B1:B16))
PLEASE NOTE: for background reasons I need to do this in a formula: using an automate script, macro, or VBA script are - unfortunately - not acceptable solutions in this situation.
Bookmarks