+ Reply to Thread
Results 1 to 8 of 8

Search VBA

  1. #1
    Registered User
    Join Date
    03-25-2012
    Location
    England
    MS-Off Ver
    Excel 2007 & Excel 2011 for Mac
    Posts
    79

    Search VBA

    hi, the following code search's for the Term "UOM" in a range of cells and if this is there then opens Userform 2 which allows the user to change certain data then writes to a different sheet. It then continues on it search until all instances of "UOM" have been found. What I'm struggling with is when it reaches the last instance of "UOM" it returns to the first instance and starts again.

    Is there anyway of stopping at the last instance??????????

    Thanks

    Please Login or Register  to view this content.

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

    Re: Search VBA

    Try something like this...

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-25-2012
    Location
    England
    MS-Off Ver
    Excel 2007 & Excel 2011 for Mac
    Posts
    79

    Re: Search VBA

    Thanks, but that doesn't seem to want to search from H5 down till the last used row in column H.

    Any ideas??

    Thanks

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

    Re: Search VBA

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    03-25-2012
    Location
    England
    MS-Off Ver
    Excel 2007 & Excel 2011 for Mac
    Posts
    79

    Re: Search VBA

    Thanks again but still struggling.

    What the top code did was find the 1st instance of "UOM" in H25 for example, then open Userform2, do its thing then jump to say H46, open Userform2 and so on. This code doesn't seem to select he 1st instance

    Thanks in Advance

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

    Re: Search VBA

    Quote Originally Posted by zhb12810 View Post
    Thanks again but still struggling.

    What the top code did was find the 1st instance of "UOM" in H25 for example, then open Userform2, do its thing then jump to say H46, open Userform2 and so on. This code doesn't seem to select he 1st instance

    Thanks in Advance
    If the first code worked then what was the problem?

    Did you have the correct sheet activated when you ran the second code?

  7. #7
    Registered User
    Join Date
    03-25-2012
    Location
    England
    MS-Off Ver
    Excel 2007 & Excel 2011 for Mac
    Posts
    79

    Re: Search VBA

    When it got to the last instance of the search term it returned to the start of the list and started searching through the same again. Basically i just want it to only ever search the range once.

    Once the search has completed another routine will run and refresh the data so that the search term should be obsolete. As more data is added the search term may reappear and the process will start again

    Thanks

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

    Re: Search VBA

    This searches once.

    Please Login or Register  to view this content.

+ 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