Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: VBA Run-time error '91' on Find string variable

  1. #1
    New Member
    Join Date
    Dec 2009
    Posts
    9
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default VBA Run-time error '91' on Find string variable

    Code:
    Range("A10").Select
    dateselect = Selection.Text
    Range("A10:B30").Select
        Selection.Copy
    Windows("Products.xlsx").Activate
    Sheets("Year").Select
    Cells.Find(What:=dateselect, After:=ActiveCell, LookIn:=xlFormulas, _
            LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False, SearchFormat:=False).Activate
    
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
    I'm getting a "run-time error '91': Object variable or With block variable not set" and the Cells.Find part is being highlighted. What's the issue?

  2. #2
    MrExcel MVP Jonmo1's Avatar
    Join Date
    Oct 2006
    Location
    Bryan, TX
    Posts
    44,054
    Post Thanks / Like
    Mentioned
    19 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA Run-time error '91' on Find string variable

    Short answer: = It didn't find what it was looking for.

    Long Answer: = Give some detail about what you want the macro to do...
    It's likely that since you set dateselect = selection.TEXT, but it's looking for a DATE on the other sheet, it won't find it. Because it's different type of value.
    try changing

    dateselect = Selection.Text
    to
    dateselect = Selection.Value
    Use the MrExcel HTML Maker to post nicely formatted tables in your forum posts.
    Find a link in post number 31

    The more we learn, and the better we get at our trade, the easier it becomes to overlook the obvious.

    Life moves pretty fast. If you don't stop and look around once in a while, you could miss it.
    Ferris Bueller A.K.A. John Hughes, 1986

  3. #3
    New Member
    Join Date
    Dec 2009
    Posts
    9
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA Run-time error '91' on Find string variable

    Thanks! Changing text to value did it.

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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