This a very easy task if you are willing to use Power Query. To demo this, instead of a picture (which I cannot manipulate), please upload your sample file.
Grouping is one of the simplest tasks that you can perform in Power Query which is on your Data Tab of the Ribbon. In your version, it is called Get and Transform Data.
You cant use power query with VBA arrays I believe. The code sent is probably quicker then writing to the workbook > using power query > writing results to workbook and then reading results to the ending array