View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
RyGuy RyGuy is offline
external usenet poster
 
Posts: 73
Default Compare and Highlight Differences

I am trying to come up with a way of comparing two ranges, which will change
over time, and put together bits of code to create the macro below:


Sub Compare2Shts()

Dim rRange As Range
Dim ws As Worksheet

Set rRange = Nothing
On Error Resume Next
Set rRange = Application.InputBox(Prompt:= _
"Please select a range for input.", _
Title:="SPECIFY RANGE", Type:=8)
On Error GoTo 0
If rRange Is Nothing Then
Exit Sub
End If


InValidEntry:
If Err = 13 Then
MsgBox "Not a valid input. " & "Please retry."
End If

rRange.Select

For Each Cell In Worksheets("Secondary").rRanage
If Cell.Value < Worksheets("Primary").rRanage Then
Cell.Interior.ColorIndex = 3
End If
Next
End Sub


I was hoping to be able to hold down the Ctrl key and click on two different
sheets and then just select a range one one sheet (and I assume the range on
the second sheet would be identical, in terms of the space covered, for the
comparison of each cell's values).

It fails on the line: rRange.Select

Can someone point out my flaw?

Thanks,
Ryan---