+ Reply to Thread
Results 1 to 5 of 5

Question on FindNext vs Find

Hybrid View

  1. #1
    excelnut1954
    Guest

    Question on FindNext vs Find

    I have a question about the FindNext coding, and how to integrate it
    with my application.

    The code below is what I have right now to perform a Find when the
    user enters a PO number in TextBox1 of a userform in order to view a
    record. The record will be on a list in a worksheet named Official
    List. This works fine. It opens up another userform, and all the fields
    are populated by the data from the requested record. Below that is the
    Change Sub that sets the variable of Textbox1 for this purpose.
    **************************************************
    Private Sub CommandButton1_Click()
    Worksheets("Official List").Activate

    Dim FoundCell As Range
    With Sheets("Official List")
    Set FoundCell = .Cells.Find(What:=FindPOVal, After:=ActiveCell, _
    LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, _
    SearchDirection:=xlNext, MatchCase:=False)

    End With

    If FoundCell Is Nothing Then
    MsgBox "Not Found - Please try again"
    Unload UserForm12
    UserForm12.Show
    Else
    ActiveWorkbook.Names.Add Name:="EditPO", RefersTo:=FoundCell

    Unload UserForm12
    UserForm13.Show

    End If
    End Sub
    ****************************************
    Private Sub TextBox1_Change()

    FindPOVal = TextBox1.Value
    End Sub
    ********************************

    I've looked at the example of FindNext, (it's still a little
    confusing) and I'm not sure if I'm suppose to use that to replace
    the coding above, or should I use it in separate coding to identify
    other PO numbers that might be on the list after the initial search is
    completed.
    In other words, should this be a 2 step process: the Find coding I have
    above, then the FindNext coding.
    Or should it all be in the FindNext coding? Hope this is clear enough
    to understand.

    Thanks,
    J.O.


  2. #2
    Tom Ogilvy
    Guest

    Re: Question on FindNext vs Find

    If you are looking for the value in FindPOVal, then you would not use
    FindNext. A new value would constitute a new search. FindNext is when
    there are multiple occurances of the same FindPOVal value in your range and
    you want to find them all.

    You will note that FindNext does not take an argument to specify what to
    look for. It "inherits" the values already specified in the Find command.

    --
    Regards,
    Tom Ogilvy

    "excelnut1954" <excelnut1954@yahoo.com> wrote in message
    news:1140102404.617021.35330@g44g2000cwa.googlegroups.com...
    > I have a question about the FindNext coding, and how to integrate it
    > with my application.
    >
    > The code below is what I have right now to perform a Find when the
    > user enters a PO number in TextBox1 of a userform in order to view a
    > record. The record will be on a list in a worksheet named Official
    > List. This works fine. It opens up another userform, and all the fields
    > are populated by the data from the requested record. Below that is the
    > Change Sub that sets the variable of Textbox1 for this purpose.
    > **************************************************
    > Private Sub CommandButton1_Click()
    > Worksheets("Official List").Activate
    >
    > Dim FoundCell As Range
    > With Sheets("Official List")
    > Set FoundCell = .Cells.Find(What:=FindPOVal, After:=ActiveCell, _
    > LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, _
    > SearchDirection:=xlNext, MatchCase:=False)
    >
    > End With
    >
    > If FoundCell Is Nothing Then
    > MsgBox "Not Found - Please try again"
    > Unload UserForm12
    > UserForm12.Show
    > Else
    > ActiveWorkbook.Names.Add Name:="EditPO", RefersTo:=FoundCell
    >
    > Unload UserForm12
    > UserForm13.Show
    >
    > End If
    > End Sub
    > ****************************************
    > Private Sub TextBox1_Change()
    >
    > FindPOVal = TextBox1.Value
    > End Sub
    > ********************************
    >
    > I've looked at the example of FindNext, (it's still a little
    > confusing) and I'm not sure if I'm suppose to use that to replace
    > the coding above, or should I use it in separate coding to identify
    > other PO numbers that might be on the list after the initial search is
    > completed.
    > In other words, should this be a 2 step process: the Find coding I have
    > above, then the FindNext coding.
    > Or should it all be in the FindNext coding? Hope this is clear enough
    > to understand.
    >
    > Thanks,
    > J.O.
    >




  3. #3
    excelnut1954
    Guest

    Re: Question on FindNext vs Find

    Ok. That answers my question. In the example given in Help for
    FindNext, it almost looked like it was performing both routines. Next,
    and FindNext.
    I'll see what I can do with the example.

    Thanks Tom
    J.O.


  4. #4
    excelnut1954
    Guest

    Re: Question on FindNext vs Find

    Thanks Tom.
    I thought from the Help example that the FindNext coding would function
    for both, Find, and FindNext.

    So, how would I go from the Find routine, to FIndNext?
    When the user is viewing a record, at what point would FindNext come
    into play?
    Would a message box appear if there is another PO to view?

    I'm not sure if I'm painting a very good picture here
    If you have an idea on how I would continue this, I would appreciate
    it.

    Thanks again
    J.O.


  5. #5
    Tom Ogilvy
    Guest

    Re: Question on FindNext vs Find

    Gather all the locations using the Find, FindNext example, then loop through
    the list showing each to the user.

    --
    Regards,
    Tom Ogilvy



    "excelnut1954" <excelnut1954@yahoo.com> wrote in message
    news:1140126352.333520.167580@z14g2000cwz.googlegroups.com...
    > Thanks Tom.
    > I thought from the Help example that the FindNext coding would function
    > for both, Find, and FindNext.
    >
    > So, how would I go from the Find routine, to FIndNext?
    > When the user is viewing a record, at what point would FindNext come
    > into play?
    > Would a message box appear if there is another PO to view?
    >
    > I'm not sure if I'm painting a very good picture here
    > If you have an idea on how I would continue this, I would appreciate
    > it.
    >
    > Thanks again
    > J.O.
    >




+ 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