Hi
Why not just create a Pivot Table.
Place your cursor within the data table>Data>Pivot Table>Finish
On the PT skeleton that appears on a new sheet,
Drag Country to the Row Area
Drag the item you wish to count to the Data area.
Double click on that field, and choose Count

Signature
Regards
Roger Govier
> Hi,
>
[quoted text clipped - 45 lines]
>
> Thanks alot in advance!
Susan - 12 Dec 2007 01:41 GMT
Hi Roger,
Thanks for the prompt response.
I need to do it programmatically as it's not a once-off task.
So i'm trying to trigger this function with a button click.
Thanks
Susan
On Dec 12, 3:22 am, "Roger Govier"
<roger@technology4unospamdotcodotuk> wrote:
> Hi
>
[quoted text clipped - 59 lines]
>
> > Thanks alot in advance!
Bill Renaud - 12 Dec 2007 18:47 GMT
<<I need to do it programmatically as it's not a once-off task.
So i'm trying to trigger this function with a button click.>>
Turn on the Macro Recorder while generating the pivot table. Post the
resulting code back here. Somebody will help you clean it up (substitute
variables, etc.), so that it is robust and works in the future, regardless
of size of data.

Signature
Regards,
Bill Renaud
Susan - 12 Dec 2007 02:01 GMT
On Dec 12, 3:22 am, "Roger Govier"
<roger@technology4unospamdotcodotuk> wrote:
> Hi
>
[quoted text clipped - 59 lines]
>
> > Thanks alot in advance!
Hi,
I still need to do it programmatically as the function will be
triggered by button click in Excel.
Thanks for responding
Priya
Roger Govier - 12 Dec 2007 13:47 GMT
Hi Susan
Assuming your countries are in column B and the values to be summed are in
column C
Also, assuming row 1 has headers, and that columns F and G are not being
used, then the following simple macro will achieve what you want.
Sub AddCountryValues()
Dim lr As Long
Columns("F:G").ClearContents
Range("B:B").AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=Range("F1"), Unique:=True
lr = Range("F65536").End(xlUp).Row
Range("G2").Select
ActiveCell.FormulaR1C1 = "=SUMIF(C[-5],C[-1],C[-4])"
Range("G2").Select
Selection.AutoFill Destination:=Range("G2:G" & lr), _
Type:=xlFillDefault
End Sub
Change all of the column references to suit

Signature
Regards
Roger Govier
> On Dec 12, 3:22 am, "Roger Govier"
> <roger@technology4unospamdotcodotuk> wrote:
[quoted text clipped - 70 lines]
>
> Priya
> Hi,
>
[quoted text clipped - 45 lines]
>
> Thanks alot in advance!
Try the SUMIF function
Susan - 12 Dec 2007 01:43 GMT
Hi,
I thought about SUMIF.
=SUMIF(G:G,"*countryValue*",E:E) is what i ideally need, where
countryValue is substituted by the respective country, but i am not
sure how to do this programmatically.
Thanks for responding
Susan