Thread: [Solved] Formula Help
View Single Post
 
Old 10-22-2017, 06:36 AM
Roger Govier Roger Govier is offline Windows 10 Office 2016
Novice
 
Join Date: Oct 2017
Location: Abergavenny, Wales, UK
Posts: 13
Roger Govier is on a distinguished road
Default

Hi

You can't do it in the same cell by formula, only with VBA.
For a formula solution, in cell G1 enter
=D1+(COUNTIF($D$11,D1)-1)*0.3 and copy down
and in H1
=E1+(COUNTIF($E$1:E1,E1)-1)*0.3

If you want to do it in the cells, then this code will change the values in columns D and E
Code:
Sub Add3()

    Dim lr As Long, i As Long, x As Long
    lr = Cells(Rows.Count, "D").End(xlUp).Row
    For i = 1 To lr
        x = Application.CountIf(Range(Cells(1, "D"), Cells(i, "D")), Cells(i, "D"))
        If x > 1 Then
            Cells(i, "D") = Cells(i, "D") + (x - 1) * 0.3
        End If
        x = Application.CountIf(Range(Cells(1, "E"), Cells(i, "E")), Cells(i, "E"))
        If x > 1 Then
            Cells(i, "E") = Cells(i, "E") + (x - 1) * 0.3
        End If
    Next i

End Sub
Reply With Quote