ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   VBA code help (https://www.excelbanter.com/excel-discussion-misc-queries/172373-vba-code-help.html)

jlclyde

VBA code help
 
Everytime I run this code it bugs out. Can anyone tell me why? I
just want to find my monkey is that so hard. I am trying to find the
word monkey on a spreadsheet and then i will be bale to create other
code to offset from this anchor. The trick is finding the monkey.

Thanks,
Jay

Sub Macro5()
Dim rFound As Range
Dim form As Worksheet

Set rFound = Sheets("RA and inspect
form").Columns(1).Find(What:="Monkey", _
After:=Sheets("RA and inspect form").Cells(1, 1),
LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False _
, SearchFormat:=False)
Set form = Sheets("RA and Inspect form")
form.Range(rFound).Select

End Sub

Bob Phillips

VBA code help
 
Try this

Sub Macro5()
Dim rFound As Range
Dim form As Worksheet

With Sheets("RA and inspect form")
Set rFound = .Columns(1).Find( _
What:="Monkey", _
After:=.Cells(1, 1), _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)
If Not rFound Is Nothing Then
.Activate
rFound.Select
End If
End With
End Sub

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"jlclyde" wrote in message
...
Everytime I run this code it bugs out. Can anyone tell me why? I
just want to find my monkey is that so hard. I am trying to find the
word monkey on a spreadsheet and then i will be bale to create other
code to offset from this anchor. The trick is finding the monkey.

Thanks,
Jay

Sub Macro5()
Dim rFound As Range
Dim form As Worksheet

Set rFound = Sheets("RA and inspect
form").Columns(1).Find(What:="Monkey", _
After:=Sheets("RA and inspect form").Cells(1, 1),
LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False _
, SearchFormat:=False)
Set form = Sheets("RA and Inspect form")
form.Range(rFound).Select

End Sub





All times are GMT +1. The time now is 02:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com