View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Roger Govier[_3_] Roger Govier[_3_] is offline
external usenet poster
 
Posts: 2,480
Default Reading values into an array of User Defined Types

Hi

Why not just create a Pivot Table.
Place your cursor within the data tableDataPivot TableFinish
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

--

Regards
Roger Govier

"Susan" wrote in message
...
Hi,

I'm new to macro programming.
I need a simple way to sum values in one column based on criteria in
another column eg number of items per country.

Im trying to program this with a array where each element points to a
User Defined Type (containing a string and double value) . I realize I
will need an outer loop to iterate through the entire column and an
inner loop to iterate through the array and add to value of same
country eg. every time I get to a row of France, I have to search for
France in my array and add to the exisiting item value or create a new
array entry for France.

Im getting tangled up in my code and have a feeling I'm doing this the
long way.
Would greatly appereciate some help:

Private Type Volumes
Country As String
Values As Double
End Type
Sub ComputeValues()

Dim rngToSearch As Range
Dim rngFound As Range
Dim mVolumes() As Volumes

Set rngToSearch = Sheets("Bill").Columns("B")
Set rngFound = rngToSearch.Find("Country")

If rngFound Is Nothing Then
MsgBox "No Range found"
Else
rngFound.Select

Set rng = Range(ActiveCell, ActiveCell.End(xlDown))

For Each cell In rng

'This is where I'm stuck

Next

End If

End Sub

Thanks alot in advance!