Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This macro will search for records based on a PO# given by the user.
Often, there are more than one record with that PO#. The code, up to the End If statement works. I wanted to add code so that I can show in UserForm13 which of the found records is showing (1 of 4, 2 of 4, etc). I already have a textbox showing the total records found. I wanted the ForEach part to "assign" a distinct number to that record, so I can show it in another textbox. Obviously, I'm not setting this up correctly. In the ForEach statement, I'm getting an error when it reads rndFound. Can someone help me with ideas on what I need to change here? Thanks Much appreciated J.O. 'These are the Standard module declarations Public rngToSearch As Range Public rngFound As Range Public strFirst As String Public FindPOVal As String Sub TestFind_POCurrent() Worksheets("Official List").Activate Set rngToSearch = Sheets("Official List").Columns("J") Set rngFound = rngToSearch.Find(What:=FindPOVal, _ LookIn:=xlValues, _ LookAt:=xlWhole) If rngFound Is Nothing Then MsgBox "This record was not found. Please try again." Unload UserForm12 UserForm12.Show Else strFirst = rngFound.Address rngFound.Selec End If Dim RecordsFound As Integer '******** this is the part showing the error, in the rngFound part. ******* '******** I thought I could use rngFound to identify each record in the range. ****** For Each rngFound In rngToSearch . RecordsFound = RecordsFound + 1 Next rngFound Unload UserForm12 UserForm13.Show End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
If statement problem | Excel Discussion (Misc queries) | |||
Problem with IF statement | Excel Worksheet Functions | |||
problem with IF statement | Excel Discussion (Misc queries) | |||
Problem with IF statement | Excel Discussion (Misc queries) | |||
ForEach procedure adding values | Excel Programming |