View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Mike Fogleman Mike Fogleman is offline
external usenet poster
 
Posts: 1,092
Default Compare and Highlight Differences

Ossie, one little change to cover a multiple column range:

For i = 1 To .Rows.Count * .Columns.Count

Mike F
"OssieMac" wrote in message
...
Hi again RyGuy,

My apologies. I forgot to finish the MsgBox to give then user the option
of
cancelling or retrying so here it is again.

Sub Compare2Shts()

Dim rRangePrimary As Range
Dim rRangeSecondary As Range
Dim wsPrimary As Worksheet
Dim wsSecondary As Worksheet
Dim strPrompt As String
Dim Response As Variant

Set wsPrimary = Sheets("Primary")
Set wsSecondary = Sheets("Secondary")

wsPrimary.Select

Set rRangePrimary = Nothing
strPrompt = "Please select a range for input."

Do
On Error Resume Next
Set rRangePrimary = Application.InputBox _
(Prompt:=strPrompt, _
Title:="SPECIFY RANGE", Type:=8)
On Error GoTo 0

If rRangePrimary Is Nothing Then
Response = MsgBox("You cancelled. " _
& "Do you want to re-try?", vbYesNo)
If Response = vbNo Then
Exit Sub
End If
End If
Loop While rRangePrimary Is Nothing

Set rRangeSecondary = wsSecondary.Range(rRangePrimary.Address)

With rRangeSecondary
For i = 1 To .Rows.Count
If .Cells(i).Value < rRangePrimary.Cells(i).Value Then
.Cells(i).Interior.ColorIndex = 3
End If
Next i
End With


End Sub

Regards,

OssieMac