Excel macro for comparing and disaplaying values

Example of Excel macro for comparing and disaplaying values

This macro compare the each value in cell B. If the value is greater than 200 then it will take value from cell A.

Sub macro()
 
    Dim i As Integer
    Dim j As Integer
    Dim rws As Integer
    
    i = 1
    j = 1
    
    rws = Cells(Rows.Count, "A").End(xlUp).Row ' to get the total number of rws in the range
    MsgBox rws
    
    Do While True
        If Range("B" & i).Value = "" Then
            Exit Sub
         End If
 
         If Range("B" & i).Value > 2000 Then
           MsgBox (Range("A" & i).Value & " --> " & Range("B" & i).Value)
        End If
        i = i + 1
    Loop
 
End Sub
By Perry    Popularity  (3219 Views)