Forum Discussion

sandeep singh's avatar
sandeep singh
Copper Contributor
Oct 05, 2018
Solved

vba -excel -how to check and compare cell value against next cell's value in same column

Private Sub CommandButton1_Click()
Dim i As Integer, j As Integer, temp As Integer, rng As Range

Set rng = Range("A1").CurrentRegion

For i = 1 To rng.Count
For j = i + 1 To rng.Count

If rng.Cells(j) < rng.Cells(i) Then
MsgBox "Alert -Entry in row is Less Than Previous Cell !!"
Exit Sub

End If

Next j

Next i

End Sub

I tried bit of coding but it does not work -I need to check value of cell while i enter data in cell

4 Replies

Resources