Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'v recently learned how to implement the Find, and FindNext commands
in some userforms I've designed. They search a list of PO numbers, and work ok. Below, I'll show the subs I have that use these commands. What I want to do now is to put in a FindPrevious button in these userforms. That way, the user can toggle each way in the list of found PO numbers. I tried to use the same concept of the FindNext, but it doesn't work. I didn't expect it to. I think I may want to re-design what I have to accomplish this better. I'm thinking that what I may want to do at the point where I do the initial Find for a PO number, is that any cell containing this PO number would get a "name" (variable name? Can't think of the term I want). Then, the FindNext would go to each of these names, and the FindPrevious would go back one record. I think if I can find out how to name all the cells that contain a PO number during this initial Find, then I might be able to figure out the rest, and how to insert this into the Find, FindNext, and FindPrevious commands. Here are the 2 subs I use the Find and FindNext commands. Sub FindViaPOCurrent() 'This is for the PO/PL search via UserForm12. Clicking the OK button 'brings you here. If record found, it opens up UserForm13 to show 'that record. The "Find Another Record" button will also loop back here. Worksheets("Official List").Activate Set rngToSearch = Sheets("Official List").Columns("J") Set rngFound = rngToSearch.Find(What:=FindPOVal, _ LookIn:=xlValues) If rngFound Is Nothing Then MsgBox "This record was not found. Make sure you entered the correct number." Worksheets("Menu").Activate Unload UserForm12 UserForm12.Show Else strFirst = rngFound.Address rngFound.Select Unload UserForm12 UserForm13.Show End If End Sub Sub FindNextViaPOCurrent() 'This is routine from clicking the "Get the next record w/ same PO..." 'button. If no duplicates found, you get message. If there is, it 'brings up UserForm13 like above. Set rngFound = rngToSearch.FindNext(rngFound) If rngFound.Address = strFirst Then MsgBox "There are no other records with this PO/PL. Search for a different PO/PL, or click Close" Else rngFound.Select Unload UserForm13 UserForm13.Show End If End Sub I would appreciate any help with this. Thanks, J.O. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
userform commnad from a sheet command | Excel Discussion (Misc queries) | |||
SUM command not working | Excel Worksheet Functions | |||
Specifying a Command Button on a worksheet as differentiated from one on a UserForm | Excel Programming | |||
Command for userform to load website link | Excel Programming | |||
Userform disappears when you try to initialize from a command button | Excel Programming |