You could mark the rows, and use the marked rows in a SUMIF or
SUMPRODUCT formula, e.g. =SUMIF(I:I,"X",E:E)
or find the row of the tenth item, and build a SUBTOTAL formula in a macro.
'=======================================
Sub MarkVisRows()
Dim rng As Range
Dim c As Range
Dim i As Integer
Set rng = ActiveSheet.AutoFilter.Range
i = 1
Columns("I").ClearContents
For Each c In rng.Columns(1).SpecialCells(xlVisible)
If c.Row 1 Then
If i 10 Then
Exit Sub
Else
c.Offset(0, 8).Value = "X"
i = i + 1
End If
End If
Next
Range("L1").Formula = "=SUMIF(E1:E" & r & ")"
End Sub
'=========================
Sub SubtotalTenRows()
Dim rng As Range
Dim c As Range
Dim i As Integer
Dim r As Long
Set rng = ActiveSheet.AutoFilter.Range
i = 1
Columns("I").ClearContents
For Each c In rng.Columns(1).SpecialCells(xlVisible)
If c.Row 1 Then
If i 10 Then
Else
r = c.Row
i = i + 1
End If
End If
Next
Range("K1").Formula = "=SUBTOTAL(9,E1:E" & r & ")"
End Sub
'=================================
dflorine < wrote:
I use a filter to sort data, then use a macro for data calculation. How
can I tell the macro to always choose the first 10 rows for the
calculation, regardless of row numbers?
--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html