E
excelnut1954
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.
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.