Macro-find and sum

P

puiuluipui

Hi, i need a macro to look in column "L" and find last cell that contain the
word "total" and to sum all cells below.
Can this be done?
Thanks allot!
 
P

Per Jessen

Hi

Look at this:

Sub Macro4()

Dim TotalCell As Range
Set TotalCell = Columns("L:L").Find(What:="Total", After:=Range("L1"),
LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlPrevious, _
MatchCase:=False)
MySum = WorksheetFunction.Sum(Range(TotalCell.Offset(1, 9),
TotalCell.End(xlDown)))
msg = MsgBox("MySum = " & MySum)
End Sub

Regards,
Per
 
D

Don Guillett

Do you ever bother to go back and look at your PREVIOUS posts BEFORE posting
again?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top