Current location - Quotes Website - Excellent quotations - Excel macro, how to write VBA to judge the contents of two cells one by one?
Excel macro, how to write VBA to judge the contents of two cells one by one?
The following is the code and detailed explanation:

Deputy General Manager ()

Rng = range ("b" & select. Row)' defines the variable rng as the row of the selected area in column B ..

If Rng. Value & lt& gtRNG. Offset (-1, 0). "ValueThen" determines whether the value of this cell is consistent with the value of its previous cell.

MsgBox "different!" If it is different, the prompt box "Different" will pop up.

Exit Sub' exits the program.

other

MsgBox "same!" If they are the same, the pop-up box prompts "same"

If ... it will be over.

End joint