moxiepilot
New Member
- Joined
- Jan 2, 2018
- Messages
- 11
So I was able to find VBA code to be able to search for a Worksheet within an open workbook. The issue is that there are going to be a lot of sheets, and remembering the exact name is going to be a challenge. Is there a way to add additional code that searches for a partial match and opens that worksheet?
The code I have so far is:
Sub FindSheet()
Dim xName As String
Dim xFound As Boolean
xName = InputBox("Enter sheet name to find in workbook:", "Sheet search")
If xName = "" Then Exit Sub
On Error Resume Next
ActiveWorkbook.Sheets(xName).Select
xFound = (Err = 0)
On Error GoTo 0
If xFound Then
MsgBox "Sheet '" & xName & "' has been found and selected!"
Else
MsgBox "The sheet '" & xName & "' could not be found in this workbook!"
End If
End Sub
Thanks for the help!
The code I have so far is:
Sub FindSheet()
Dim xName As String
Dim xFound As Boolean
xName = InputBox("Enter sheet name to find in workbook:", "Sheet search")
If xName = "" Then Exit Sub
On Error Resume Next
ActiveWorkbook.Sheets(xName).Select
xFound = (Err = 0)
On Error GoTo 0
If xFound Then
MsgBox "Sheet '" & xName & "' has been found and selected!"
Else
MsgBox "The sheet '" & xName & "' could not be found in this workbook!"
End If
End Sub
Thanks for the help!