View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Macro to Sum Arrays of Various Size

Houston,

Take out the spaces and use a pivot table.

Or use a macro like this, to enter the sums in column B:

Sub EnterSums()
Dim myArea As Range

For Each myArea In Range("B:B").SpecialCells(xlCellTypeConstants).Are as
myArea.Cells(myArea.Cells.Count + 1).Formula = "=SUM(" & myArea.Address & ")"
Next myArea
End Sub

HTH,
Bernie
MS Excel MVP


"ConfusedNHouston" wrote in message
...
I have about 1500 sets of data in a single column that I need to sum,
individually.

Example

Product A $500
Product A $200
Product A $150

Product B $200
Product B $100

I can write a macro that searches for the empty cell (below $150 for Product
A and below $100 for product B), and I could then use the sum function; but
in one case I'm summing 3 terms, in the second case, I'm summing 2. I don't
know how to "tell the macro" (I'm assuming it's a relative reference macro),
how to determine the number of terms to sum.

Thanks, as always....