I am working with an Excel spreadsheet that needs nested subtotals. I know I can do this in a pivotTable but most of the code to process this worksheet is already done. I just need the subtotal part. I used the subtotal function but it doesn't give me what I want. I am attaching a copy of what I have now and what I want. I want the Main subtotal to show up above the groupings and I want the nested subtotal to show up below the groupings. So I think I will need to loop through each of the two ranges, compare one row to another and determine if they are the same or not. If they are the same then I would accumulate the totals. If they are not then I would put out the subtotal. I'm not exactly sure of the best way to do this in code. Any help would be appreciated.