View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Very complex Loop

Hi,

If i've understood correctly this does what you want. Right click your sheet
tab, view code and paste this in and run it

Sub human()
Set myrange = Range("A2:A100")
For Each c In myrange
Count = Count + 1
If c.Value < c.Offset(-1, 0).Value Then
c.Offset(-1, 1).Value = 1 / Count
Count = 0
End If
Next
End Sub

Mike

"LuisE" wrote:

I need to loop thru B1:B100 to place a number in each cell in that range
following this criterion: in A1:A100, every time the value changes, I need
to count the total occurrences of that value and divide 1 by that number (of
occurrences) then place that result in each correspondent cell in column B
then move to the next unique value and do the same. Obviously the data in
column A is sorted in order to avoid duplicates.


Thanks in advance