Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro query - finding mutliple occurences of text in a column

Hi all

I have a list of various words in a column and a correspondin
numerical value for it in an adjacent column.

I would like a macro that "scans" down the column of words and adds th
corresponding numerical values for a particular word (see attache
file). For example in the attached file it could look for the wor
"petrol" and add 20 and 15 to return 35.

I've had a stab at a macro involving "find", "match", "offset" etc wit
no joy... I wondered if anyone would be able to post suitable cod
suggestions?

Eventually I'd like for the search word (eg. "petrol") to be specifie
in a list and the macro to search for all words in a list - is thi
possible?

Any help would be much appreciated. Apologies that I posted a simila
thread - I don't think my query was very clear. I'm very keen t
automate this in a macro and steer clear of pivot tables!

Many thanks for your time.

Nei

Attachment filename: neilmacro.xls
Download attachment: http://www.excelforum.com/attachment.php?postid=66550
--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro query - finding mutliple occurences of text in a column

dim rng as Range
set rng = Range(cells(1,1),Cells(1,1).End(xldown))
msgbox Application.Sumif(rng,"petrol",rng.offset(0,1))

I didn't look at your file, but you are describing the sumif
worksheetfunction. You can use it as shown.

as written, it assumes the words are in column A, starting in A1 and the
corresponding numbers in Column B

--
Regards,
Tom Ogivy

"Mcneilius " wrote in message
...
Hi all

I have a list of various words in a column and a corresponding
numerical value for it in an adjacent column.

I would like a macro that "scans" down the column of words and adds the
corresponding numerical values for a particular word (see attached
file). For example in the attached file it could look for the word
"petrol" and add 20 and 15 to return 35.

I've had a stab at a macro involving "find", "match", "offset" etc with
no joy... I wondered if anyone would be able to post suitable code
suggestions?

Eventually I'd like for the search word (eg. "petrol") to be specified
in a list and the macro to search for all words in a list - is this
possible?

Any help would be much appreciated. Apologies that I posted a similar
thread - I don't think my query was very clear. I'm very keen to
automate this in a macro and steer clear of pivot tables!

Many thanks for your time.

Neil

Attachment filename: neilmacro.xls
Download attachment:

http://www.excelforum.com/attachment.php?postid=665501
---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro query - finding mutliple occurences of text in a column

Many thanks for that Tom, works a treat!

I'm fairly new to macros, but I should be able to read up on Sumif an
modify the code accordingly, if for example, the range doesn't start i
A1, or I need the search word (eg. "petrol") to be be specified in
cell, shouldn't I?

Thanks again for your help, very much appreciated.

Kind regards

Nei

--
Message posted from http://www.ExcelForum.com

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
Counting Unique occurences of text in a column Tan Excel Worksheet Functions 12 October 26th 09 04:21 PM
Counting Unique occurences of text in a column Bernd P Excel Worksheet Functions 0 October 25th 09 10:47 AM
How do I count the # of unique occurences of a text in a column? Rob Kaiser Excel Worksheet Functions 10 November 21st 07 09:16 PM
count text occurences in a column Daniel_ITSM Excel Discussion (Misc queries) 20 March 7th 07 08:46 PM
Excel Macro Query - Search for specific text in cells of a column Mcneilius Excel Programming 2 August 29th 04 05:12 PM


All times are GMT +1. The time now is 06:28 AM.

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"