I set up a spreadsheet with a find macro, works no problem. Now I am copying the macro to a new spreadsheet that is set up EXACTLY as the one it is coming from and I cannot get the macro to work. What happened? The text in red below is where the debugger keeps on highlighting.
Sub Find()
Dim sFind As String
Dim rSearch As Range
Dim cl As Range
sFind = Sheets("HDM Find").Range("A1")
With Sheets("EMLT Range Planner")
'set range to search, limit it used cells in range
Set rSearch = .Range(.Cells(1, 3), .Cells(.Rows.Count, 1).End(xlUp))
With rSearch
Set cl = .Find(What:=sFind, After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not cl Is Nothing Then '< find successful
cl.Offset(0, -1).Copy
Sheets("HDM Find").Range("A2").PasteSpecial
'<- change this to do something with the found cell
Else: MsgBox sFind & " not found"
End If
End With
End With
End Sub
Sub Find()
Dim sFind As String
Dim rSearch As Range
Dim cl As Range
sFind = Sheets("HDM Find").Range("A1")
With Sheets("EMLT Range Planner")
'set range to search, limit it used cells in range
Set rSearch = .Range(.Cells(1, 3), .Cells(.Rows.Count, 1).End(xlUp))
With rSearch
Set cl = .Find(What:=sFind, After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not cl Is Nothing Then '< find successful
cl.Offset(0, -1).Copy
Sheets("HDM Find").Range("A2").PasteSpecial
'<- change this to do something with the found cell
Else: MsgBox sFind & " not found"
End If
End With
End With
End Sub