Excel Macro Help

  • Thread starter Thread starter Jean
  • Start date Start date
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
 
Do you need to do it in code? You could use the SUMIF worksheet function. Quite simple - examples are in the on line help.
 
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)
 
Back
Top