Tuesday, August 9, 2011

Matching Data With in 2 Range :


if You want to Match the Data Between Two Range, You can use this Macro : 
Both Range must be Same,

Sub matchValue()
On Error resume Next
Application.ScreenUpdating = False

Dim F_range As Range
Dim S_range As Range

Set F_range = Application.InputBox("Please Select 1st Range", , , , , , , 8)
Set S_range = Application.InputBox("Please Select 2nd Range", , , , , , , 8)
Dim r As Integer
Dim c As Integer
r = F_range.Rows.Count
c = F_range.Columns.Count
Dim cc As Integer
Dim rc As Integer
For cc = 1 To c
For rc = 1 To r
'For Each cell In F_range.Cells
If F_range.Cells(rc, cc).Value = S_range.Cells(rc, cc).Value Then
Else
F_range.Cells(rc, cc).Font.Bold = True
F_range.Cells(rc, cc).Color = 2
F_range.Cells(rc, cc).Interior.ColorIndex = 31
S_range.Cells(rc, cc).Font.Bold = True
S_range.Cells(rc, cc).Interior.ColorIndex = 31
End If
Next rc
Next cc
Application.ScreenUpdating = True
Range("A1").Select
End Sub

No comments: