ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   help with find macro. (https://www.excelbanter.com/excel-programming/360433-help-find-macro.html)

funkymonkUK[_148_]

help with find macro.
 

hi i am getting an error message of "runtime 91: Object variable or with
block variable not set"

this is my code:

Sub test2()
Dim cell As Object
Dim strFileFound As String
For Each cell In Range("a11:a56")

cell.Activate
Range("i11").Select
Selection.CurrentRegion.Select
strFileFound = Selection.Find(what:=ActiveCell.Value & " for " &
Range("e4").Value, LookIn:=xlValues, lookat:=xlPart).Value
If strFileFound < "" Then ActiveCell.Offset(0, 1).Value = "Found"
Beep
Next cell
End Sub

It keeps on highlighting the line which starts with "strfilefound..."


--
funkymonkUK
------------------------------------------------------------------------
funkymonkUK's Profile: http://www.excelforum.com/member.php...o&userid=18135
View this thread: http://www.excelforum.com/showthread...hreadid=538409


Don Guillett

help with find macro.
 
IF? you are trying to put "found" in the next column for a find, I suggest
you look in vba help index for FINDNEXT. There is an excellent example you
can easily modify without selections.


--
Don Guillett
SalesAid Software

"funkymonkUK"
wrote in message
...

hi i am getting an error message of "runtime 91: Object variable or with
block variable not set"

this is my code:

Sub test2()
Dim cell As Object
Dim strFileFound As String
For Each cell In Range("a11:a56")

cell.Activate
Range("i11").Select
Selection.CurrentRegion.Select
strFileFound = Selection.Find(what:=ActiveCell.Value & " for " &
Range("e4").Value, LookIn:=xlValues, lookat:=xlPart).Value
If strFileFound < "" Then ActiveCell.Offset(0, 1).Value = "Found"
Beep
Next cell
End Sub

It keeps on highlighting the line which starts with "strfilefound..."


--
funkymonkUK
------------------------------------------------------------------------
funkymonkUK's Profile:
http://www.excelforum.com/member.php...o&userid=18135
View this thread: http://www.excelforum.com/showthread...hreadid=538409




Tom Ogilvy

help with find macro.
 
Sub test2()
Dim cell As Object
Dim rng as Range
For Each cell In Range("a11:a56")

Range("i11").Select
Selection.CurrentRegion.Select
set rng = Selection.Find(what:=Cell.Value & " for " & _
Range("e4").Value, LookIn:=xlValues, lookat:=xlPart)
If not rng is nothing then _
cell.Offset(0, 1).Value = "Found"
beep
Next cell
End Sub

--
Regards,
Tom Ogilvy


"funkymonkUK" wrote:


hi i am getting an error message of "runtime 91: Object variable or with
block variable not set"

this is my code:

Sub test2()
Dim cell As Object
Dim strFileFound As String
For Each cell In Range("a11:a56")

cell.Activate
Range("i11").Select
Selection.CurrentRegion.Select
strFileFound = Selection.Find(what:=ActiveCell.Value & " for " &
Range("e4").Value, LookIn:=xlValues, lookat:=xlPart).Value
If strFileFound < "" Then ActiveCell.Offset(0, 1).Value = "Found"
Beep
Next cell
End Sub

It keeps on highlighting the line which starts with "strfilefound..."


--
funkymonkUK
------------------------------------------------------------------------
funkymonkUK's Profile: http://www.excelforum.com/member.php...o&userid=18135
View this thread: http://www.excelforum.com/showthread...hreadid=538409



funkymonkUK[_149_]

help with find macro.
 

Many thanks Tom that worked great thank you


--
funkymonkUK
------------------------------------------------------------------------
funkymonkUK's Profile: http://www.excelforum.com/member.php...o&userid=18135
View this thread: http://www.excelforum.com/showthread...hreadid=538409



All times are GMT +1. The time now is 07:27 PM.

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