How to write a for loop to get the range between a ,b columns
This compares the cell in column A to the cell in column B on the same row.
If there is a match, then the message box will identify which row.
Sub rngCompare()
lr = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
Set rng = ActiveSheet.Range("A2:A" & lr)
For Each c In rng
If c.Value = c.Offset(0,1).Value Then
MsgBox "Bingo on row " & c.Row
End If
Next
End Sub
"tom" wrote in message
...
Dim x,y As Integer
NumRows = Range("B3", Range("B3").End(xlDown)).Rows.Count
Range("C2").Select
For x = 1 To NumRows
For y= cells(A).value to cells(B).value
'which code we have to write for comparing a1,b1 are equal or not
ActiveCell.FormulaR1C1 = "=Sum(RC[-1]+1)"
ActiveCell.Offset(x, 0).FillDown
Next
Next
|