Question : Excel - Find if a value is in the top 25 %, 50% or 75% of the total value

Is it possible with VBA
1. get the sum of column 3,
2. and then in column 4 determine if value in column 3 is
- in the top1-25% range (If so put an A in the cell)
- in the 26- 50% range (If so put an B in the cell)
- in the 51- 75-% range (If so put an C in the cell)
- orin the bottom 25% (If so put an D in the cell)

Answer : Excel - Find if a value is in the top 25 %, 50% or 75% of the total value

Sorry, wasn't minding my relative references.  This works; note the absolute row references:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
Sub DoTheMath()
 
    Dim LastR As Long
 
    With ActiveSheet
        LastR = .Cells(.Rows.Count, "c").End(xlUp).Row
        .Range("d2:d" & LastR).Formula = "=VLOOKUP(PERCENTRANK(C$2:C$" & LastR & _
            ",C2),{0,""D"";0.2500001,""C"";0.5000001,""B"";0.7500001,""A""},2)"
        .Range("b" & (LastR + 2)) = "Total"
        .Range("c" & (LastR + 2)).Formula = "=SUM(C2:C" & LastR & ")"
    End With
 
End Sub
Random Solutions  
 
programming4us programming4us