I'm trying to figure out excel VBA code to add subtotal (=SUBTOTAL(9,__:_) formulas to multiple Total Rows within a worksheet (red boxed. The issue is that the range for the subtotals can be any height. Per the image below, the hope is that the VBA code would be able to identify when "Total" is present in column B and then proceed to add a subtotal formula in that row for columns E to J. The subtotal formula would need to pull the above balances up until there is a blank cell in order to calculate the amount for the particular client (the length of the range is signified by the arrows in the image below). The range could be any number of rows so has to be fully variable.
In addition, trying to add a subtotal at the very bottom of the worksheet (last row +2) that should extend up to the very top of the row (blue arrow).
Finally, I need to find a way to copy the client name (green rectangles in column B) next to the total cells (copy to column C). The number of invoices can vary for each client so it would have to identify where the client name is located and then copy the name down to the bottom where the client total is being calculated.
Any help in this would be greatly appreciated!!
In addition, trying to add a subtotal at the very bottom of the worksheet (last row +2) that should extend up to the very top of the row (blue arrow).
Finally, I need to find a way to copy the client name (green rectangles in column B) next to the total cells (copy to column C). The number of invoices can vary for each client so it would have to identify where the client name is located and then copy the name down to the bottom where the client total is being calculated.
Any help in this would be greatly appreciated!!