This will work on column B:
Sub TryNow()
Dim Counter As Integer
For Counter = 1 To Range("B65536").End(xlUp).Row
Dim Found As Range
Dim St1 As Variant
St1 = Range("B" & Counter).Value
Set Found = Range(Range("B" & Counter), _
Range("B65536").End(xlUp)).Find(What:=St1, _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
MatchCase:=False)
Dim message1 As String
If Not Found Is Nothing And Found.Row < Counter Then
message1 = "Found " & St1 & " in " & Str(Found.Row)
Else
message1 = St1 & " of row " & Str(Counter) & " not found"
End If
Cells(Counter, 3).Value = message1
Next
End Sub
However, if you would describe what you really want to do, it may be easier
another way, like a formula.....
HTH,
Bernie
MS Excel MVP
"bagsakan " wrote in message
...
Hi,
im new at excel+vba scripting because the person maintaining our
scripts just packed up and left.
anyway all i want to do is to make sure that certain columns do not
have duplicate entries, and if there are then i want to notify the user
of their locations.
basically here is what i got
For counter = 1 To LastRow(ThisWorkbook.ActiveSheet)
Dim found As Long
st1 = Range("A" & counter)
found = Cells.Find(What:=st1, _
After:=Range("A" & counter), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
Dim message1 As String
If found = 0 And found < counter Then
message1 = "Found " & st1 & " in " & Str(found)
Else
message1 = st1 & " of row " & Str(counter) & " not found"
End If
Cells(counter, 3).Value = message1
Next
i am currently doing this on a test workbook. if i move the columns
to be checked to another column (say column B) and update the 'After'
parameter to reflect the change then the macro doesnt work anymore.
can somebody point out what i am doing wrong? thanks.
regards...
---
Message posted from http://www.ExcelForum.com/