-
Hi Hammond,
Not sure how many places you are putting this/or similar formula updating in, so a simple example.
This should update the formula in cell A1. If just in one cell, maybe use the Worksheet Change event amd limit to changes in L Col.
[vba]
Sub FindOnes()
Dim FirstRange As Range
Dim LastRange As Range
Set FirstRange = Range("L:L").Find(1, Cells(Rows.Count, "L"), xlValues, _
xlWhole, xlByColumns, xlNext)
Set LastRange = Range("L:L").Find(-1, Cells(1, "L"), xlValues, xlWhole, _
xlByColumns, xlPrevious)
If FirstRange Is Nothing _
Or LastRange Is Nothing _
Then Exit Sub
Range("A1").Formula = "=-SUMPRODUCT((L" & FirstRange.Row & ":L" & LastRange.Row & ")" & _
"*(M" & FirstRange.Row & ":M" & LastRange.Row & "))"
End Sub
[/vba]
Hope that helps,
Mark
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules