+ Reply to Thread
Results 1 to 2 of 2

A Macro to search and sum

  1. #1
    Registered User
    Join Date
    02-16-2006
    Posts
    1

    A Macro to search and sum

    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

  2. #2
    Tom Ogilvy
    Guest

    Re: A Macro to search and sum

    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


    --
    Regards,
    Tom Ogilvy

    "SteFau" <[email protected]> wrote in
    message news:[email protected]...
    >
    > 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
    >
    >
    > --
    > SteFau
    > ------------------------------------------------------------------------
    > SteFau's Profile:

    http://www.excelforum.com/member.php...o&userid=31625
    > View this thread: http://www.excelforum.com/showthread...hreadid=513205
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1