A Macro to search and sum

  • Thread starter Thread starter SteFau
  • Start date Start date
S

SteFau

Hey guys,

Ok, I'm a kind of newbie to Excel Macro Programming but have a small
basic programming knowledge. So here goes my Question...

What code would I need to search a given colum for a specific string,
and IF the string is found, i would want to add up the number in a
column of the same line. The sum would be put in an empty cell, doesn't
matter really where.

Can you guys help me out?

Thanx in advance!

Stephane
 
Dim c as Range, mysum as Double
Dim firstAddress as String
With Worksheets(1).Range("a1:a500")
Set c = .Find("Hobart", lookin:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
mysum = mysum + cells(c.row,"F").Value
Set c = .FindNext(c)
Loop While c.Address <> firstAddress
End If
End With
MsgBox Mysum
 

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

Back
Top