Hi
Works for me. In G3:
=SUMPRODUCT(ISNUMBER(SEARCH({"[P1","[P2"},G4:G842))*SUBTOTAL(109,OFFSET(F4:F842,ROW(F4:F842)-MIN(ROW(F4:F842)),0,1,1)))
Row 10 is hidden and has a text with [P1
[TABLE="width: 2"]
<tbody>[TR]
[TH] [/TH]
[TH="width: 30, align: center"]E[/TH]
[TH="align: center"]F[/TH]
[TH="align: center"]G[/TH]
[TH="width: 30, align: center"]H[/TH]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: right"] [/TD]
[TD="align: right"] [/TD]
[TD="align: right"] [/TD]
[TD="align: right"] [/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: right"] [/TD]
[TD="align: right"] [/TD]
[TD="align: right"] [/TD]
[TD="align: right"] [/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: right"] [/TD]
[TD="align: left"]Result[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"] [/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: right"] [/TD]
[TD="align: right"] [/TD]
[TD="align: right"] [/TD]
[TD="align: right"] [/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: right"] [/TD]
[TD="align: right"] [/TD]
[TD="align: right"] [/TD]
[TD="align: right"] [/TD]
[/TR]
[TR]
[TD="align: center"]6[/TD]
[TD="align: right"] [/TD]
[TD="align: right"] [/TD]
[TD="align: right"] [/TD]
[TD="align: right"] [/TD]
[/TR]
[TR]
[TD="align: center"]7[/TD]
[TD="align: right"] [/TD]
[TD="align: right"] [/TD]
[TD="align: right"] [/TD]
[TD="align: right"] [/TD]
[/TR]
[TR]
[TD="align: center"]8[/TD]
[TD="align: right"] [/TD]
[TD="align: right"]1[/TD]
[TD="align: left"]XXXX [p1 XXXX[/TD]
[TD="align: right"] [/TD]
[/TR]
[TR]
[TD="align: center"]9[/TD]
[TD="align: right"] [/TD]
[TD="align: right"]2[/TD]
[TD="align: left"]WWWW[/TD]
[TD="align: right"] [/TD]
[/TR]
[TR]
[TD="align: center"]11[/TD]
[TD="align: right"] [/TD]
[TD="align: right"]4[/TD]
[TD="align: left"]ZZZZ [p2] ZZZZ[/TD]
[TD="align: right"] [/TD]
[/TR]
[TR]
[TD="align: center"]12[/TD]
[TD="align: right"] [/TD]
[TD="align: right"]5[/TD]
[TD="align: left"]VVVV[/TD]
[TD="align: right"] [/TD]
[/TR]
[TR]
[TD="align: center"]13[/TD]
[TD="align: right"] [/TD]
[TD="align: right"]6[/TD]
[TD="align: left"]TTTT[/TD]
[TD="align: right"] [/TD]
[/TR]
[TR]
[TD="align: center"]14[/TD]
[TD="align: right"] [/TD]
[TD="align: right"] [/TD]
[TD="align: right"] [/TD]
[TD="align: right"] [/TD]
[/TR]
[TR]
[TD="colspan: 5"] [Book1]Sheet1[/TD]
[/TR]
</tbody>[/TABLE]