E
excelnut1954
Here is a macro that works. It will find a record in a sheet named
Official List via a PO# given by the user.
Sub FindFirst()
'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.
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. You might want to check the
Deleted List. Go to the Navigator for 'Find Deleted Record' button."
Else
strFirst = rngFound.Address
rngFound.Select
Unload UserForm12
UserForm13.Show
End If
End Sub
In the Declarations in the same module, I have this:
Private rngToSearch As Range
Private rngFound As Range
Public strFirst As String
Public FindPOVal As String
I wanted to duplicate this proceedure in another sub that will find a
record in a sheet named Deleted List, that is in the same workbook. It
will then open up different userforms than is shown above. (a different
look at the records)
Here is the Find code to look for a record in the Deleted List:
Sub FindDeleted()
'Same routine as FindFirst, except that this searches the Deleted List.
Set rngToSearch = Sheets("Deleted List").Columns("J")
Set rngFound = rngToSearch.Find(What:=FindPOVal, _
LookIn:=xlValues)
If rngFound Is Nothing Then
MsgBox "The record you requested was not found on this list."
Else
strFirst = rngFound.Address
rngFound.Select '<<<error is at this line
Unload UserForm14
UserForm15.Show
End If
End Sub
As you can see, then only thing different is the sheet name, and the
userforms involved.
I get an error in the Else section in the line
rngFound.Select
Does this error have to do with the Declarations statements? Is there a
problem with using these same statements to execute the Find in both
subs?
Anybody have a solution? I'm sure it's something simple. But, probably
about something I haven't learned yet.
Thanks
J.O.
Official List via a PO# given by the user.
Sub FindFirst()
'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.
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. You might want to check the
Deleted List. Go to the Navigator for 'Find Deleted Record' button."
Else
strFirst = rngFound.Address
rngFound.Select
Unload UserForm12
UserForm13.Show
End If
End Sub
In the Declarations in the same module, I have this:
Private rngToSearch As Range
Private rngFound As Range
Public strFirst As String
Public FindPOVal As String
I wanted to duplicate this proceedure in another sub that will find a
record in a sheet named Deleted List, that is in the same workbook. It
will then open up different userforms than is shown above. (a different
look at the records)
Here is the Find code to look for a record in the Deleted List:
Sub FindDeleted()
'Same routine as FindFirst, except that this searches the Deleted List.
Set rngToSearch = Sheets("Deleted List").Columns("J")
Set rngFound = rngToSearch.Find(What:=FindPOVal, _
LookIn:=xlValues)
If rngFound Is Nothing Then
MsgBox "The record you requested was not found on this list."
Else
strFirst = rngFound.Address
rngFound.Select '<<<error is at this line
Unload UserForm14
UserForm15.Show
End If
End Sub
As you can see, then only thing different is the sheet name, and the
userforms involved.
I get an error in the Else section in the line
rngFound.Select
Does this error have to do with the Declarations statements? Is there a
problem with using these same statements to execute the Find in both
subs?
Anybody have a solution? I'm sure it's something simple. But, probably
about something I haven't learned yet.
Thanks
J.O.