+ Reply to Thread
Results 1 to 4 of 4

help with find macro.

  1. #1
    Forum Contributor funkymonkUK's Avatar
    Join Date
    01-07-2005
    Location
    London, England
    Posts
    500

    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..."

  2. #2
    Don Guillett
    Guest

    Re: 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
    dguillett1@austin.rr.com
    "funkymonkUK" <funkymonkUK.278din_1146658264.7588@excelforum-nospam.com>
    wrote in message
    news:funkymonkUK.278din_1146658264.7588@excelforum-nospam.com...
    >
    > 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
    >




  3. #3
    Tom Ogilvy
    Guest

    RE: 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
    >
    >


  4. #4
    Forum Contributor funkymonkUK's Avatar
    Join Date
    01-07-2005
    Location
    London, England
    Posts
    500
    Many thanks Tom that worked great thank you

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1