View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ivyleaf Ivyleaf is offline
external usenet poster
 
Posts: 141
Default Compare Sheets values by .find loop?

On Apr 6, 7:41*am, Office_Novice
wrote:
greetings

i am stuck, i have two lists, both with the same information, but in
differnt places what i need is *this

If Cell A1. value = "Anything on sheet (2) Column A" then do nothing

else if Cell A1. Value < *"Anything on sheet (2) Column A" then

highlight *A1, I know not too tough, but here is where i get stuck..

After searching for Cell A1.value i need to search the rest of column A's
cells against Sheet (2) Column A

any help would be great.


Hi,

Sub compareVals()
Dim SrcList As Range, ChkList As Range
Dim cell As Range, FoundRng As Range

Set SrcList = Range("C1:C19")
Set ChkList = Range("A1:A19")

On Error Resume Next
For Each cell In SrcList
Set FoundRng = ChkList.Find(cell)
If FoundRng Is Nothing Then
MsgBox "No match for " & cell & " in " & ChkList.Address
Else
MsgBox "Found " & cell & " in " & ChkList.Address
End If
Next
End Sub

This will loop through one range and let you know if it finds the cell
from range 1 in range 2 or not. Just change the definition of the
ranges to match you needs.

Cheers,
Ivan.