+ Reply to Thread
Results 1 to 8 of 8

Find, offset and clear loop bombs out

  1. #1
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Find, offset and clear loop bombs out

    I'm getting 'Object variable or with block variable not set' on the Loop. I know it's because firstAddress has been cleared and it's being called later in the formula, however, if I don't clear it, it duplicates the cel content in the offset and leaves the original -- I want to move the value, rather than duplicate it. Is there a way to avoid this?

    Please Login or Register  to view this content.

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Find, offset and clear loop bombs out

    Hi numbnuts

    First address is a String so I believe it should be written
    Please Login or Register  to view this content.
    or perhaps
    Please Login or Register  to view this content.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Find, offset and clear loop bombs out

    Thanks Jaslake, the IsNull statement worked -- the other resulted in Type Mismatch again -- but now I'm getting 'End With without With', when clearly It's been declared at the beginning of the statement. If I remove it, any End With after the line I just deleted bombs with the same message. <sigh...>

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Find, offset and clear loop bombs out

    Hi numbnuts

    The Code is incomplete
    Please Login or Register  to view this content.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Find, offset and clear loop bombs out

    @ John,

    The Is operator is reserved to object variables.

    @ nn,

    Here's some general information on Range.Find

    Basic Range.Find Method

    You should explicitly set LookIn, LookAt, SearchOrder (if you care), and MatchByte on each invocation (or the initial invocation in a straight-line section of code) of the Find method, as all persist each time Find is invoked via VBA or Find is invoked from the user interface. (MatchCase and SearchFormat persist from invocation to invocation in the UI, but not in VBA).
    Please Login or Register  to view this content.
    The Bad Find Example in Help

    (The variable names are changed below to agree with those above)
    Please Login or Register  to view this content.
    That Loop While line should NEVER be used. If rFind Is Nothing, then rFind.Address will error; and if rFind has an Address, then it is not Nothing. (VBA always evaluates all arguments to a logical expression; if it paid attention to the And operator and quit after evaluating the first, it wouldn't be a problem.)

    If the search ultimately ends because you are destroying (as in the Help example above) or hiding the found value (as in the example below), then use

    Please Login or Register  to view this content.
    If it ends because you are finding the first entry again, then you should use
    Please Login or Register  to view this content.
    If either could happen then
    Please Login or Register  to view this content.
    Last edited by shg; 04-01-2013 at 12:55 PM.
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Find, offset and clear loop bombs out

    Yeah -- I tried filling in the blanks... Problem is, after I do, the Loop statement bombs again.

    Is it just me, or is this actually funny? lol

  7. #7
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Find, offset and clear loop bombs out

    Your notes gave me a mini-migraine, shg... but after I worked it out and applied it, Brilliant!

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Find, offset and clear loop bombs out

    Thanks guys!

+ 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