Totaling (Subtotaling) a Changing Filtered Range
I'm not sure why you're going up 3 rows to find the last row to be included, but
maybe you could just modify that formula line:
..Offset(1, 2).FormulaR1C1 = "=SUBTOTAL(9,R2C:R[-3]C)"
R2C means row 2, same column.
R[-3]C means up 3 rows, same column.
Corrie wrote:
I am trying to total a range that is filtered to "X". My problem is
the range ("x"'d items) will change with new data. I was able to count
down to the last cell and execute a subtotal but it is a specified
range. Is there code I can use that will allow the range to be dynamic
(total whatever is filtered no matter the range)?
This is what I have...
Dim destCell As Range
Set destCell = Worksheets("6Pk").Cells(Rows.Count, "A") _
With destCell
.Offset(1, 0).Value = "Filled by 6Pk"
.Offset(1, 1).Value = "X"
.Offset(1, 2).FormulaR1C1 = "=SUBTOTAL(9,R[-335]C:R[-3]C)"
--
Dave Peterson
|