comparing cells in one column to another

C

cparsons

I found a way around this but copying the cell value from th
spreadsheet to a temporary string variable. Then I compared tha
temporary variable to the array.

Is there a better way
 
B

bdcrisp

' This cycles through the target column and displays matches b
reporting
' the array element with the corresponding value

' you can initiate the call : CAll FindValueInArray(3) ' this woul
check column C

Sub FindValueInArray(TargetColumn As Integer)
On Error Resume Next

Dim RowCount As Long
Dim ArrayIndex As Integer
Dim CompareValue As Variant
Dim CompareCell As Object

For RowCount = 1 To ActiveSheet.UsedRange.Rows.Count
For ArrayIndex = 1 To UBound(myarray)
Set CompareCell = ActiveSheet.Cells(RowCount, TargetColumn)

If CompareCell.Value = myarray(ArrayIndex) Then
MsgBox ("Match Found: " & CompareCell.Value & " in arra
element: " & ArrayIndex)
End If
Next ArrayIndex
Next RowCount

End Su
 
Top