+ Reply to Thread
Results 1 to 4 of 4

.find problem passing a varibale

  1. #1
    Registered User
    Join Date
    11-14-2013
    Location
    oklahoma
    MS-Off Ver
    Excel 2010
    Posts
    4

    .find problem passing a varibale

    I would like to find the location of a cell that contains the same value as a cell in a different worksheet using the .find method.

    Here is my code:

    Please Login or Register  to view this content.
    The first message box displays the value "NAME" in the box.
    I recieve an error (Runtime error 91 Object Variable or with block variable not set)
    This error happens before the second mssage box appears.

    The code works if I replace
    Please Login or Register  to view this content.
    What do I need to do to get the variable containing a cell address to work with the .Find?
    Last edited by alansidman; 11-14-2013 at 11:13 AM. Reason: code tags added

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: .find problem passing a varibale

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (I have added them this time. Please read all forum rules and comply in the future.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: .find problem passing a varibale

    Perhaps the Value in B3 contains a trailing space "NAME " and it cannot find an exact match.

    Also, it may be better to include the other arguments for the .Find method to avoid unexpected results.

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  4. #4
    Registered User
    Join Date
    11-14-2013
    Location
    oklahoma
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: .find problem passing a varibale

    AlphaFrog... That did it. I did have a space trailing the name.

    Also the error negoatiating code helped...thanks!

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: .find problem passing a varibale

    You're welcome. Glad it worked out.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Sumproduct in varibale text array
    By Ada01 in forum Excel General
    Replies: 2
    Last Post: 03-22-2012, 05:13 PM
  2. Replies: 1
    Last Post: 11-02-2010, 10:26 AM
  3. Problem passing value to function
    By prod75 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-15-2009, 10:21 AM
  4. Help in this code for range with varibale
    By psk in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-28-2005, 10:48 AM
  5. problem on passing value
    By alvin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-11-2005, 02:06 PM

Tags for this Thread

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