+ Reply to Thread
Results 1 to 8 of 8

object variable not set

  1. #1
    Registered User
    Join Date
    07-07-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    4

    object variable not set

    hi..i am new at vba
    when i did not select the cell with the "hello" inside, i encounter an error that says object variable or with block variable not set. what does it means?

    Please Login or Register  to view this content.
    Last edited by galaxtor; 07-14-2009 at 09:58 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: object variable not set

    Try this:
    Please Login or Register  to view this content.
    EDIT: Roy's note about xlValues didn't stop my search for "hello", but it may on your sheet. Things happen. Changing to xlValues may be the thing to do.
    Last edited by JBeaucaire; 07-14-2009 at 03:23 AM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: object variable not set

    You search was looking at Formulas, not a a value, I've also changed selection for UsedRange so that it is not necessary to select the range.
    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Valued Forum Contributor
    Join Date
    05-14-2009
    Location
    gold coast
    MS-Off Ver
    Excel 2007
    Posts
    843

    Re: object variable not set

    ............................
    Last edited by D_Rennie; 07-14-2009 at 03:25 AM.

  5. #5
    Registered User
    Join Date
    07-07-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: object variable not set

    THANK YOU JBeaucaire , royUK, D_Rennie!!!

    its working already and i've understand your points =)

  6. #6
    Registered User
    Join Date
    07-07-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    4

    object variable not set (continued)

    hello..yst i posted on this issue object variable not set. i've realise there is an error.

    i tried JBeaucaire codes..it was working fine..until i selected on the active cell, it prompt me item was not found.

    i also tried royUK codes..it could find the info..but when the info is not found, it did not prompt me the error msg but instead it came out the Object variable or with block variable not set..

    anyone can help?

    so far this is what i did.
    Please Login or Register  to view this content.
    Last edited by Paul; 07-14-2009 at 09:58 PM. Reason: Moved post to end of previous thread and removed 'SOLVED' prefix

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: object variable not set

    maybe this amended code will help
    Please Login or Register  to view this content.

  8. #8
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: object variable not set

    You could shorten things a bit with an array or two:
    Please Login or Register  to view this content.
    Did you only want the error message if no items are found, or if any of the items are not found?
    Remember what the dormouse said
    Feed your head

+ 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