Spreadsheet: 862121d1709892308-how-to-count-matching-groups-of-cells-and-reference-this-at-the-end-of-a-formula-how-to-automatically-count-groups-of-cells-and-list-them-in-a-cell-formula
Sheet: What I want

 | copy path | path I want |  | filename | filename with textjoin | copy pasted into values
 | C:\Users\OK\OK2\OK3\OK4\AB\0531 |  |  |  |  | 0531 0532 0533 0534 0535 0536 0537 0538 0539 0540 0541 0542 0543 0544 0545 0546 0547 0548 0549 0550 0551 0552 0553 0554 0555 0556 0557 0558 0559 Test Sheet 21819.pdf Test Sheet 21820.pdf Test Sheet 21821.pdf Test Sheet 21822.pdf Test Sheet 21823.pdf Test Sheet 21824.pdf Test Sheet 21825.pdf Test Sheet 21826.pdf Test Sheet 21827.pdf Test Sheet 21828.pdf Test Sheet 21829.pdf Test Sheet 21830.pdf Test Sheet 21831.pdf Test Sheet [PHONE].pdf Test Sheet 21832.pdf Test Sheet 21833.pdf Test Sheet 21834.pdf Test Sheet 21835.pdf Test Sheet 21836.pdf Test Sheet 21837.pdf Test Sheet 21838.pdf Test Sheet 21839.pdf Test Sheet [PHONE].pdf Test Sheet 21841.pdf Test Sheet [PHONE].pdf Test Sheet [PHONE].pdf Test Sheet [PHONE].pdf |  | I want the formula in column C to work for all cells in the column.
 | C:\Users\OK\OK2\OK3\OK4\AB\0532 |  |  |  |  |  |  | What this means is that e.g. [NAME] has the formula =TEXTBEFORE(TEXTAFTER(B2,"\",5),"\",-1)&" ([NAME]:B21)&")" which results in the shortened file path that I require AND displays the number of occurences that the file path occurs below this first instance (up until Cell C30, which is where the file path changes to OK4\FAT\CTF1).
 | C:\Users\OK\OK2\OK3\OK4\AB\0533
 | C:\Users\OK\OK2\OK3\OK4\AB\0534
 | C:\Users\OK\OK2\OK3\OK4\AB\0535
 | C:\Users\OK\OK2\OK3\OK4\AB\0536 |  |  |  |  |  |  | This is, however, a manual process, as I have to manually adjust the COUNTA Formula boundaries.
 | C:\Users\OK\OK2\OK3\OK4\AB\0537
 | C:\Users\OK\OK2\OK3\OK4\AB\0538 |  |  |  |  |  |  | Is there anyway to make a formula that I can have in C2 and drag it all the way down so that it fits for the rest of the filepaths and displays the (x20), ([NAME]), (x14) as requested? (and so on as there are 1000 rows on my master sheet)
 | C:\Users\OK\OK2\OK3\OK4\AB\0539
 | C:\Users\OK\OK2\OK3\OK4\AB\0540
 | C:\Users\OK\OK2\OK3\OK4\AB\0541
 | C:\Users\OK\OK2\OK3\OK4\AB\0542
 | C:\Users\OK\OK2\OK3\OK4\AB\0543
 | C:\Users\OK\OK2\OK3\OK4\AB\0544
 | C:\Users\OK\OK2\OK3\OK4\AB\0545
 | [NAME]
 | C:\Users\OK\OK2\OK3\OK4\AB\0547
 | C:\Users\OK\OK2\OK3\OK4\AB\0548
 | C:\Users\OK\OK2\OK3\OK4\AB\0549
 | C:\Users\OK\OK2\OK3\OK4\AB\0550
 | C:\Users\OK\OK2\OK3\OK4\AB\0551
 | C:\Users\OK\OK2\OK3\OK4\AB\0552
 | C:\Users\OK\OK2\OK3\OK4\AB\0553
 | C:\Users\OK\OK2\OK3\OK4\AB\0554
 | C:\Users\OK\OK2\OK3\OK4\AB\0555
 | C:\Users\OK\OK2\OK3\OK4\AB\0556
 | C:\Users\OK\OK2\OK3\OK4\AB\0557
 | C:\Users\OK\OK2\OK3\OK4\AB\0558
 | C:\Users\OK\OK2\OK3\OK4\AB\0559
 | C:\Users\OK\OK2\OK3\OK4\FAT\CTF1\Test Sheet 21819.pdf
 | C:\Users\OK\OK2\OK3\OK4\FAT\CTF1\Test Sheet 21820.pdf
 | C:\Users\OK\OK2\OK3\OK4\FAT\CTF1\Test Sheet 21821.pdf
 | C:\Users\OK\OK2\OK3\OK4\FAT\CTF1\Test Sheet 21822.pdf
 | C:\Users\OK\OK2\OK3\OK4\FAT\CTF1\Test Sheet 21823.pdf
 | C:\Users\OK\OK2\OK3\OK4\FAT\CTF1\Test Sheet 21824.pdf
 | C:\Users\OK\OK2\OK3\OK4\FAT\CTF1\Test Sheet 21825.pdf
 | C:\Users\OK\OK2\OK3\OK4\FAT\CTF1\Test Sheet 21826.pdf
 | C:\Users\OK\OK2\OK3\OK4\FAT\CTF1\Test Sheet 21827.pdf
 | C:\Users\OK\OK2\OK3\OK4\FAT\CTF1\Test Sheet 21828.pdf
 | C:\Users\OK\OK2\OK3\OK4\FAT\CTF1\Test Sheet 21829.pdf
 | C:\Users\OK\OK2\OK3\OK4\FAT\CTF1\Test Sheet 21830.pdf
 | C:\Users\OK\OK2\OK3\OK4\FAT\CTF1\Test Sheet 21831.pdf
 | C:\Users\OK\OK2\OK3\OK4\FAT\CTF2\Test [NAME] [PHONE].pdf
 | C:\Users\OK\OK2\OK3\OK4\FAT\CTF2\Test [NAME] 21832.pdf
 | C:\Users\OK\OK2\OK3\OK4\FAT\CTF2\Test [NAME] 21833.pdf
 | C:\Users\OK\OK2\OK3\OK4\FAT\CTF2\Test [NAME] 21834.pdf
 | C:\Users\OK\OK2\OK3\OK4\FAT\CTF2\Test [NAME] 21835.pdf
 | C:\Users\OK\OK2\OK3\OK4\FAT\CTF2\Test [NAME] 21836.pdf
 | C:\Users\OK\OK2\OK3\OK4\FAT\CTF2\Test Sheet 21837.pdf
 | C:\Users\OK\OK2\OK3\OK4\FAT\CTF2\Test [NAME] 21838.pdf
 | C:\Users\OK\OK2\OK3\OK4\FAT\CTF2\Test [NAME] 21839.pdf
 | C:\Users\OK\OK2\OK3\OK4\FAT\CTF2\Test [NAME] [PHONE].pdf
 | C:\Users\OK\OK2\OK3\OK4\FAT\CTF2\Test Sheet 21841.pdf
 | C:\Users\OK\OK2\OK3\OK4\FAT\CTF2\Test [NAME] [PHONE].pdf
 | C:\Users\OK\OK2\OK3\OK4\FAT\CTF2\Test [NAME] [PHONE].pdf
 | C:\Users\OK\OK2\OK3\OK4\FAT\CTF2\Test [NAME] [PHONE].pdf