It isn't clear ..
- if there can be more (or less) than 2 OUT values in the row, but there will be at least one OUT
- if there are lots of rows like this to deal with
- if there is a maximum number of columns that the data can occupy
My suggestion below assumes ..
- there can be more/less than 2 OUT values in the row
- the are not too many of these rows to deal with as I have used the
volatile OFFSET function which may adversely affect your sheet performance if too many of these formulas are used on your sheet.
- data does not go beyond column Z
- that you are using Excel 2007 or later
Formulas in column A are stand-alone
Formulas in column B are copied across as far as you might need
Row 4 is used as a helper row.
These formulas may need further tweaking depending on just what might occur in your sheet.
If this doesn't meet your needs, please give more examples of sample data and expected results.
mzi
<colgroup><col style="font-weight:bold; width:30px; "><col style="width:41px;"><col style="width:41px;"><col style="width:41px;"><col style="width:41px;"><col style="width:41px;"><col style="width:41px;"><col style="width:41px;"><col style="width:41px;"><col style="width:41px;"><col style="width:41px;"><col style="width:41px;"><col style="width:41px;"><col style="width:41px;"></colgroup><tbody>
[TD="bgcolor: #cacaca, align: center"]1[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]0[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"]OUT[/TD]
[TD="align: center"]4[/TD]
[TD="align: center"].[/TD]
[TD="align: center"].[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]6[/TD]
[TD="align: center"]OUT[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]3[/TD]
[TD="bgcolor: #cacaca, align: center"]2[/TD]
[TD="align: center"]3[/TD]
[TD="align: center"]11[/TD]
[TD="align: center"]4[/TD]
[TD="bgcolor: #cacaca, align: center"]3[/TD]
[TD="align: center"]3[/TD]
[TD="align: center"]5[/TD]
[TD="align: center"]2[/TD]
[TD="bgcolor: #cacaca, align: center"]4[/TD]
[TD="align: center"]4[/TD]
[TD="align: center"]10[/TD]
[TD="align: center"]26[/TD]
[TD="bgcolor: #cacaca, align: center"]5[/TD]
</tbody>
Spreadsheet Formulas |
Cell | Formula | A2 | =SUM(OFFSET(A1,0,0,1,A4)) | B2 | =IF(B4="","",SUM(OFFSET($A1,0,A4,1,B4-A4))) | A3 | =COUNTA(OFFSET(A1,0,0,1,A4))-1 | B3 | =IF(B4="","",COUNTA(OFFSET($A1,0,A4,1,B4-A4))-1+(C4="")) | A4 | =MATCH("OUT",A1:Z1,0) | B4 | =IF(COLUMNS($B4:B4)>COUNTIF($A1:$Z1,"OUT"),"",IFERROR(MATCH("OUT",INDEX($A1:$Z1,A4+1):Z1,0)+A4,COLUMNS($A1:$Z1))) |
<tbody>
</tbody> |
<tbody>
</tbody>