Excel Macro Help

J

Jean

I'm trying to create a macro under excel which will traverse
columns and rows comparing strings. I am very familiar with
vbscript, but not sure how to do this in excel...

For example, I have 6 rows, 3 columns like this:

apple RDC 2
orange RDP 1
apple RDA 4
squash RDD 3
apple RAA 6
orange RAS 1


I would like the script to return the results:
12 apple
2 orange
1 squash

(ignoring the middle column)

Can anyone help or get me started with some sample code? Thanks!!

Jean
 
G

Guest

Do you need to do it in code? You could use the SUMIF worksheet function. Quite simple - examples are in the on line help.
 
B

Bob Phillips

Jean,

Worksheet functions will do it for you.

For example

=SUMIF(A1:A100,"apple",C1:C100)

You could also test 2 conditions

=SUMPRODUCT((A1:A100="apple")*(B1:B100="RDC"),(C1:C100))

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

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