Here's a couple of codes for you.
The first will work OK on a Mac but does require the data to be presorted as you posted. That's easily done if needed.
The second in really only for your interest since it uses the scripting dictionary which in general doesn't work on a Mac. But this code doesn't need pre-sorted data.
Both were tested on the data you posted in Sheets"Raw Data"), with consolidation on the (initially assumed empty) Sheets("sheet3") and Sheets("sheet4") respectively.
Note also that the results may look different because the original formats haven't been transferred, and neither have the column headers. Both easily done if needed.
and
Bookmarks