Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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


--
SteFau
------------------------------------------------------------------------
SteFau's Profile: http://www.excelforum.com/member.php...o&userid=31625
View this thread: http://www.excelforum.com/showthread...hreadid=513205

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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" wrote in
message ...

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Search Macro Gary Excel Discussion (Misc queries) 1 March 29th 07 04:53 PM
Search In a Macro/VBA cbanks Excel Discussion (Misc queries) 2 May 4th 06 10:34 PM
Search macro carg1[_7_] Excel Programming 4 November 18th 04 07:17 PM
Excel XP VBA code to search all macro code in Excel module for specific search string criteria Ed[_18_] Excel Programming 4 May 20th 04 02:08 PM
Excel XP VBA code to search all macro code in Excel module for specific search string criteria Frank Kabel Excel Programming 0 May 19th 04 08:11 PM


All times are GMT +1. The time now is 01:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"