rossbritton26
New Member
- Joined
- Jul 28, 2011
- Messages
- 33
Hi,
I have a spreadsheet with around 200 sheets in, each sheet has a name containing a policy number and there is normally another small part such as 01-000. I have the following code:
Sub FindPolicy()
Dim SearchData As String
SearchData = InputBox("Enter policy number here")
If SearchData <> vbNullString Then
On Error Resume Next
Sheets(SearchData).Activate
If Err.Number <> 0 Then MsgBox "Cannot Find The Specified Policy Number " & SearchData
On Error GoTo 0
End If
End Sub
This code works when i know the exact name of the sheet i am looking for. However, i do not always know the exact name as the additional numbers at the end of the name vary, and can sometimes be in a different format. Also, there may be more than one sheet for each policy, with a different code at the end. Ideally, i'd search for a policy number and would then be able to choose from a list of sheets for that number.
Any ideas?
Thanks,
Ross
I have a spreadsheet with around 200 sheets in, each sheet has a name containing a policy number and there is normally another small part such as 01-000. I have the following code:
Sub FindPolicy()
Dim SearchData As String
SearchData = InputBox("Enter policy number here")
If SearchData <> vbNullString Then
On Error Resume Next
Sheets(SearchData).Activate
If Err.Number <> 0 Then MsgBox "Cannot Find The Specified Policy Number " & SearchData
On Error GoTo 0
End If
End Sub
This code works when i know the exact name of the sheet i am looking for. However, i do not always know the exact name as the additional numbers at the end of the name vary, and can sometimes be in a different format. Also, there may be more than one sheet for each policy, with a different code at the end. Ideally, i'd search for a policy number and would then be able to choose from a list of sheets for that number.
Any ideas?
Thanks,
Ross