I am having trouble creating a macro that will find a specified value in my active sheet within a range in my \"Information\" sheet. If the cell value us not found in the range
You want to avoid .Select
/.Activate
Sub testRot2()
Dim str As String
Dim srchRng As Range
With Worksheets(ActiveSheet.Name)
str = .Cells(2, 5).Value
Set srchRng = .Range("J8:J17").Find(what:=str)
If srchRng Is Nothing Then
MsgBox "Not found"
End If
End With
End Sub
Also, note that I changed i
to str
. This is a personal choice, as I typically see i
as a Long
/Integer
for looping. You can keep it i
though, just thought to mention it. Also, note the colon required in Find(what:=str)
.