View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
keiji kounoike keiji kounoike is offline
external usenet poster
 
Posts: 199
Default computations at odd but specified locations

One way. I presumed Segment in column A, Value in column B, Percentage
in column C.

Sub Sumtest()
Dim tmp As Range, Total As Range, sTotal As Range, rng As Range
Dim i As Long

Set Total = Columns("B").SpecialCells(xlCellTypeConstants, 1)

For i = 1 To Total.Areas.Count
Set tmp = Total.Areas(i)
tmp.Offset(, 1).NumberFormat = "0.0%"
Set sTotal = tmp.Resize(1).Cells(tmp.Cells.Count + 1)
sTotal.Formula = "=sum(" & tmp.Address(False, False) & ")"
For Each rng In tmp
rng.Offset(, 1).Formula = "=" & rng.Address(False, False) & _
"/" & sTotal.Address(False, False)
Next
Next
End Sub

Keiji

Utkarsh wrote:
Hi

Apologies to those who are seeing it again. Since there was no
response on excel.misc group I'm posting here.

I have data available as follows:

Segment Value Percentage
A 2
B 7
C 5
Total
X 3
Y 2
Total
Q 4
W 6
E 3
R 8
Total


Unforrtunately, as you can see, the rows are unequal. I need to put
totals in the cell adjacent to where "Total" occurs. Also, based on
the totals percentage break-ups for each group needs to be computed.
Can someone suggest a way out?