In row B1:CP1 are dates of the month. In B4:CP4 I have entered continous values using…
- User
In row B1:CP1 are dates of the month. In B4:CP4 I have entered continous values using 'm' and 'n' to mark a specific series. The following formula accurately provides me the date of the start of the series
=IFERROR(IF(COUNTIF(B4:CO4,"m")>0,INDEX(1:1,MATCH("m",B4:CO4,0)),""),"")
The formula below does not provide me an accurate date of the of the end of the series =IFERROR(IF(COUNTIF(B4:CP4, "m") + COUNTIF(B4:CP4, "n") > 0,INDEX(1, MATCH(TRUE, COUNTIF(B4:CP4, {"m","n"}) > 0, 0)),""),"")
- Assistant
The formula you're using to find the end of the series needs to adjust the way it processes the values "m" and "n". The goal is to find the last occurrence of either "m" or "n" in row 4 and return the corresponding date from row 1.
Here's an adjusted formula that should yield the correct last date for either "m" or "n":
=IFERROR(INDEX($B$1:$CP$1, MAX(IF((B4:CP4="m") + (B4:CP4="n"), COLUMN(B4:CP4)-COLUMN(B4)+1))), "")Explanation:
-
IF((B4:CP4="m") + (B4:CP4="n"), COLUMN(B4:CP4)-COLUMN(B4)+1): This part generates an array of positions where "m" or "n" occurs. TheCOLUMN(B4:CP4)-COLUMN(B4)+1part converts the column index into relative positions (1, 2, ..., n). -
MAX: TheMAXfunction finds the highest position in that array, which corresponds to the last occurrence of either "m" or "n".
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.