Log in

View Full Version : Excel formula help needed.


Shaun
27th February 2016, 03:05 PM
I currently use this formula

=IF(A1="","",IF(A1="end","",MATCH("?*",INDEX(A:A,1+MATCH(B1,A:A,0)):A$1048576,0)))
to get this result.

<b>Excel 2010</b><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #BBB"><colgroup><col width="25px" style="background-color: #DAE7F5" /><col /><col /><col /></colgroup><thead><tr style=" background-color: #DAE7F5;text-align: center;color: #161120"><th></th><th>A</th><th>B</th><th>C</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">1</td><td style=";">test1</td><td style=";">test1</td><td style="text-align: right;;">5</td></tr><tr ><td style="color: #161120;text-align: center;">2</td><td style="text-align: right;;"></td><td style=";">data</td><td style=";"></td></tr><tr ><td style="color: #161120;text-align: center;">3</td><td style="text-align: right;;"></td><td style=";">data</td><td style=";"></td></tr><tr ><td style="color: #161120;text-align: center;">4</td><td style="text-align: right;;"></td><td style=";">data</td><td style=";"></td></tr><tr ><td style="color: #161120;text-align: center;">5</td><td style="text-align: right;;"></td><td style=";">data</td><td style=";"></td></tr><tr ><td style="color: #161120;text-align: center;">6</td><td style=";">test2</td><td style=";">test2</td><td style="text-align: right;;">4</td></tr><tr ><td style="color: #161120;text-align: center;">7</td><td style="text-align: right;;"></td><td style=";">data</td><td style=";"></td></tr><tr ><td style="color: #161120;text-align: center;">8</td><td style="text-align: right;;"></td><td style=";">data</td><td style=";"></td></tr><tr ><td style="color: #161120;text-align: center;">9</td><td style="text-align: right;;"></td><td style=";">data</td><td style=";"></td></tr><tr ><td style="color: #161120;text-align: center;">10</td><td style=";">test3</td><td style=";">test3</td><td style="text-align: right;;">3</td></tr><tr ><td style="color: #161120;text-align: center;">11</td><td style="text-align: right;;"></td><td style=";">data</td><td style=";"></td></tr><tr ><td style="color: #161120;text-align: center;">12</td><td style="text-align: right;;"></td><td style=";">data</td><td style=";"></td></tr><tr ><td style="color: #161120;text-align: center;">13</td><td style=";">end</td><td style="text-align: right;;"></td><td style=";"></td></tr></tbody></table><p style="width:3.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #BBB;border-top:none;text-align: center;background-color: #DAE7F5;color: #161120">Sheet1</p><br /><br />

But what i need is for it to be modified to ignore blank spaces so i can get this result.

<b>Excel 2010</b><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #BBB"><colgroup><col width="25px" style="background-color: #DAE7F5" /><col /><col /><col /></colgroup><thead><tr style=" background-color: #DAE7F5;text-align: center;color: #161120"><th></th><th>F</th><th>G</th><th>H</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">1</td><td style=";">test1</td><td style=";">test1</td><td style="text-align: right;;">4</td></tr><tr ><td style="color: #161120;text-align: center;">2</td><td style="text-align: right;;"></td><td style=";">data</td><td style=";"></td></tr><tr ><td style="color: #161120;text-align: center;">3</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";"></td></tr><tr ><td style="color: #161120;text-align: center;">4</td><td style="text-align: right;;"></td><td style=";">data</td><td style=";"></td></tr><tr ><td style="color: #161120;text-align: center;">5</td><td style="text-align: right;;"></td><td style=";">data</td><td style=";"></td></tr><tr ><td style="color: #161120;text-align: center;">6</td><td style=";">test2</td><td style=";">test2</td><td style="text-align: right;;">3</td></tr><tr ><td style="color: #161120;text-align: center;">7</td><td style="text-align: right;;"></td><td style=";">data</td><td style=";"></td></tr><tr ><td style="color: #161120;text-align: center;">8</td><td style="text-align: right;;"></td><td style=";">data</td><td style=";"></td></tr><tr ><td style="color: #161120;text-align: center;">9</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";"></td></tr><tr ><td style="color: #161120;text-align: center;">10</td><td style=";">test3</td><td style=";">test3</td><td style="text-align: right;;">3</td></tr><tr ><td style="color: #161120;text-align: center;">11</td><td style="text-align: right;;"></td><td style=";">data</td><td style=";"></td></tr><tr ><td style="color: #161120;text-align: center;">12</td><td style="text-align: right;;"></td><td style=";">data</td><td style=";"></td></tr><tr ><td style="color: #161120;text-align: center;">13</td><td style=";">end</td><td style="text-align: right;;"></td><td style=";"></td></tr></tbody></table><p style="width:3.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #BBB;border-top:none;text-align: center;background-color: #DAE7F5;color: #161120">Sheet1</p><br /><br />

walkermac
27th February 2016, 05:53 PM
I hacked at your code and got the following, which appears to work: =IF(A1="","",IF(A1="end","",COUNTIF(INDIRECT("b"&ROW(B1)&":b"&ROW(B1)+MATCH("?*",INDEX(A:A,1+MATCH(B1,A:A,0)):A$1048576,0)-1),"*")))

Shaun
27th February 2016, 10:53 PM
Got to love those guys on the MrExcel forum.

=IF(F1="","",COUNTA(G1:G$13)-SUM(H2:H$13))

Thamks for the help walkermac

Shaun
27th February 2016, 11:07 PM
Sorry, both those formulas still count the space because it has a formula in it.

Shaun
27th February 2016, 11:30 PM
They came up with a similar code to your, just more compact.

=IF(F1="","",COUNTIF(G1:G$13,"?*")-SUM(H2:H$13))