There are many ways of accomplishing the desired output, here are few alternative ways which works based on ones Excel Version they are using(MS365 versions updated)

• Formula used in cell F2
=LET(
a, A2:D9,
b, SCAN(,IF(INDEX(a,,2)="",TAKE(a,,1),""),LAMBDA(x,y,IF(y="",x,y))),
c, GROUPBY(b,CHOOSECOLS(a,2,4),SUM,,0,,b<>0),
VSTACK({"Department","Total Qty","Total Amount"}, c))
This can also be accomplished using Power Query, available in Windows Excel 2010+ and Excel 365 (Windows or Mac)

To use Power Query follow the steps:
- First convert the source ranges into a table and name it accordingly, for this example I have named it as
Table1
- Next, open a blank query from Data Tab --> Get & Transform Data --> Get Data --> From Other Sources --> Blank Query
- The above lets the Power Query window opens, now from Home Tab --> Advanced Editor --> And paste the following M-Code by removing whatever you see, and press Done
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
AddedCondition = Table.AddColumn(Source, "Dept", each if [Quantity] = null then [Description] else null),
FillDown = Table.FillDown(AddedCondition,{"Dept"}),
Filter = Table.SelectRows(FillDown, each [Description] <> null and [Description] <> ""),
Answer = Table.Group(Filter, {"Dept"}, {{"Total Quantity#(tab)", each List.Sum([Quantity]), type nullable number}, {"Total Amount", each List.Sum([Amount]), type nullable number}})
in
Answer
- Lastly, to import it back to Excel --> Click on Close & Load or Close & Load To --> The first one which clicked shall create a New Sheet with the required output while the latter will prompt a window asking you where to place the result.
Also, if you are not interested in using these above, then also it can be achieved using Pivot Tables.

- First, add a helper column after the amount column, and enter the following formula and fill down (note that you will need to change the cell range and references as per your data:
=IF(K2="",J2,N1)
- Select any cell in the data and hit ALT+D+P it opens up the
Pivot Table and PivotChart Wizard
- Step One --> Don't press anything by default, it will selected
Pivot Table, press only Next
- Second Step --> Verify the wizard has selected the required range and hit
Next
- Third Step --> You can either select
New Worksheet or Existing Worksheet with preferred cell references to place the pivot and hit Finish
- From the
Pivot Table Fields add the Helper in Rows Area while the Qty and Amt in the Values Area
- Change the layout of the
Pivot from the Design tab to Tabular Form and change the helper header to Dept or whatever suits you best. Other necessary formatting you can do as per your requitements. This will give you the exact output you needed.