Forum Discussion
bilalahmedd
Apr 05, 2023Copper Contributor
Moving down 1 row while checking certain condition
I want to create a macro which checks if values of year 2018 is greater than 2017 and then checks if values of 2019 were greater than 2018 and so on. For 2027, if i enter any value it should similar...
OliverScheurich
Apr 05, 2023Gold Contributor
Sub comparison()
Dim i, j As Long
Range("C:C").Clear
j = Range("A" & Rows.Count).End(xlUp).Row
For i = 3 To j
If Cells(i, 2).Value > Cells(i - 1, 2).Value Then
Cells(i, 3).Value = "increase in comparison to year " & Cells(i - 1, 1)
Else
End If
Next i
End SubMaybe with these lines of code. In the attached file you can click the button in cell G2 to run the macro.