Step 1 : Create new sheet, Insert -> Pivot Table. Set range of Data to CTC!$A:$D .
Step 2 : Set Pivot Table fields like it is shown below. Press on sub family and filter out blanks.
Step 3 : In Excel tabs choose Design -> Subtotals -> Do not show Subtotals.
In Excel tabs choose Design -> Grand Totals -> Do not show Grand Totals.
To show row labels side-by side press on any grade number -> Excel tab Analyze -> Active Field -> Field Settings -> Layout and Print -> check Show item labels in tabular form.
Right Click anywhere on PivotTable. Choose PivotTable options. Set Merge cells with labels on.
Step 4 : Make sure your table is called PivotTable1 and it is placed on Sheet1. Otherwise you will have to edit VBA a bit.
Step 5 : Create button on CTC Sheet and assign VBA to it.