View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
BrianB BrianB is offline
external usenet poster
 
Posts: 1
Default How to find and sub total a specific number of cell above the target cell

Try this. It uses the SUM function but adjusts as necessary.

'=============================================
Sub test()
Dim FoundCell As Object
With ActiveSheet.Columns(1)
Set FoundCell = .Find("Summary", LookIn:=xlValues)
If Not FoundCell Is Nothing Then
FirstAddress = FoundCell.Address
Do
ActiveSheet.Cells(FoundCell.Row, 2).FormulaR1C1 = _
"=SUM(R[-3]C:R[-1]C)"
Set FoundCell = .FindNext(FoundCell)
Loop While Not FoundCell Is Nothing _
And FoundCell.Address < FirstAddress
End If
End With
End Sub
'=============================================


---
Message posted from http://www.ExcelForum.com/