I have expenses sheets where various columns of figures need to be totalled according to the filter criteria in the costs centre column.
I had been trying the subtotal 9/109 function expecting that to work, but it seems you can only subtotal if the column is filtered on its own values.
The user imports data into the sheet and the relevant columns total.
The user can then use the filter to isolate a list of any particular cost centre.
The subtotal should then adjust to sum only the visible values.
This si the code I am using
this totally doesnt work.
When filtered on column "M", the subtotal stays the same. WHen filtered on column "D" it changes.
A simple formula works fine... =SUBTOTAL(9,D2:D20)
but this is not good to me because the user needs to be able to add unknown number of rows.
Should the subtotal function be acting like this?
Maybe find last row and paste in a formula?
thanks
Thanks
I had been trying the subtotal 9/109 function expecting that to work, but it seems you can only subtotal if the column is filtered on its own values.
The user imports data into the sheet and the relevant columns total.
The user can then use the filter to isolate a list of any particular cost centre.
The subtotal should then adjust to sum only the visible values.
This si the code I am using
Code:
ThisWorkbook.Sheets("CCRead").Range("d" & Lastrow + 1) = Application.WorksheetFunction.Subtotal(9, ThisWorkbook.Sheets("CCRead").Range("d2:d" & Lastrow))
this totally doesnt work.
When filtered on column "M", the subtotal stays the same. WHen filtered on column "D" it changes.
A simple formula works fine... =SUBTOTAL(9,D2:D20)
but this is not good to me because the user needs to be able to add unknown number of rows.
Should the subtotal function be acting like this?
Maybe find last row and paste in a formula?
thanks
Thanks