+ Reply to Thread
Results 1 to 5 of 5

'Find' not working as expected (Excel vba).

  1. #1
    Registered User
    Join Date
    12-07-2012
    Location
    London, England
    MS-Off Ver
    Office 2010
    Posts
    81

    'Find' not working as expected (Excel vba).

    Hi,

    I have a routine that should look down a range of several columns of around 10K rows each for 'SearchItem'.
    It needs to be columns because the first column is most likely to contain the item being looked for.

    Here's the code.

    Please Login or Register  to view this content.

    I've obviously done something wrong, because here's what happened.

    It worked exactly as hoped. Once. And then it never worked again. After that first time it just kept finding cell F3,

    which is part of the range, but has always been empty. Since it did work once, I assume that the reason it doesn't now is something to do with the settings for After, LookIn, LookAt, etc.

    I really need this to work, and if anyone can put me right I'd be deeply grateful.

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: 'Find' not working as expected (Excel vba).

    what is FindString?
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Forum Contributor
    Join Date
    04-11-2011
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    325

    Re: 'Find' not working as expected (Excel vba).

    Try this code instead. You call the function from another routine as needed. You will have to change the worksheet "Your worksheet of data" to whatever sheet you want to search.

    Please Login or Register  to view this content.
    EDIT: Also, if you are searching for the same string of text everytime then of course you will find it in the same place. Hopefully that's not the issue here.
    Last edited by 111StepsAhead; 01-18-2013 at 11:41 AM. Reason: Code change. Now function works with many routines.

  4. #4
    Registered User
    Join Date
    12-07-2012
    Location
    London, England
    MS-Off Ver
    Office 2010
    Posts
    81

    Re: 'Find' not working as expected (Excel vba).

    'if you are searching for the same string of text every time'

    Dammit. I hadn't noticed that. The code is doing the right thing, but the wrong variable name was there, and I didn't notice.

    Sorry people, false alarm. On the bright side, at least it means I did get the code correct (almost).

    Again, sorry about that.

  5. #5
    Registered User
    Join Date
    12-07-2012
    Location
    London, England
    MS-Off Ver
    Office 2010
    Posts
    81

    Re: 'Find' not working as expected (Excel vba).

    And thank you 111steps for that code. It will come in handy.

+ 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