+ Reply to Thread
Results 1 to 5 of 5

VBA Find() question

  1. #1
    Registered User
    Join Date
    04-14-2009
    Location
    Arkansas, USA
    MS-Off Ver
    Excel 2007
    Posts
    6

    VBA Find() question

    I'm trying to use the find function to make my macros easier to handle, but I don't know how to run through all instances of what I'm trying to find and then stop. Currently I just have my find function in an infinite loop and it stops when it runs into an error. This works well I guess, but I'd like to know how to stop after the last instance without error. Here's the code that I have been using:

    Please Login or Register  to view this content.
    I've done some searches and found some code that checks to see if the find function returns a range. I've tried this method, but because I know nothing about this language, I'm having a hard time figuring out where my code is messing up. Here's the code that I'm trying to code now:

    Please Login or Register  to view this content.
    The code I'm replacing with "'Unimportant code here" has been tested and works fine. The program runs into an error at "Set rFound = ...". Does anybody know what I'm doing wrong?

    --dorky
    Last edited by dorkydude666; 04-20-2009 at 01:43 PM.

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

    Re: VBA Find() help

    The code that's there is important if it changes the contents of rFound to eliminate the left paren.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988

    Re: VBA Find() help

    Moved to programming....

    Your post does not comply with Rule 5 of our Forum RULES. We have Seven question forums: Miscellaneous, General, Programming, Worksheet Functions, Charting, Excel 2007 Help and New Users. Please choose the appropriate forum, and post your question in ONLY one forum.

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  4. #4
    Registered User
    Join Date
    04-14-2009
    Location
    Arkansas, USA
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: VBA Find() question

    Sorry about putting it in the wrong forum.

    rFound is not changed with my code. Now that I think about it though, do you think that .Activate at the end is changing what rFound is supposed to be?

    Consider the differences between:

    Please Login or Register  to view this content.
    and

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-14-2009
    Location
    Arkansas, USA
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: VBA Find() question

    Ah ha! Beautiful. Thanks for the tip. Problem solved using above solution.

+ 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