ajaypal_sp
New Member
- Joined
- Feb 11, 2015
- Messages
- 25
HI,
I'm trying to find repeated text in a particular column ("A2:A21") by using "Find" Method. At '.Find' code, iam getting "Type Mismatch" error. Pls go through the below code and help me.
Best Regards
Ajaypal
I'm trying to find repeated text in a particular column ("A2:A21") by using "Find" Method. At '.Find' code, iam getting "Type Mismatch" error. Pls go through the below code and help me.
Code:
Option Explicit
Sub returnrepeatedtextcelladdresses()
Dim l As Variant
Dim rng, rfound As Range
Dim i, r As Integer
l = Thisworkbook.Worksheets("sheet3").Cells(Rows.Count, "a").End(xlUp).Row
l = Cells(l, 1).Address
i = 1
Set rng = Thisworkbook.Worksheets("sheet3").Range("a2:a21")
Do While Cells(i, 1).Address <> l
Set rfound = rng.Find(What:="AJAY", After:=Cells(i, 1), _
LookIn:=xlValues, LookAt:=xlWhole, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False)
r = rfound.Row
i = r
MsgBox rfound.Address
Loop
End Sub
Best Regards
Ajaypal