Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have code to select worksheets using an inputbox box. I am using the code
below, but what is happening when someone puts in a name for a sheet that can't be matched is it returns the first sheetname i.e. SHEET 1. What I would like it to do is to return an error message. The code I have is as follows: Private Sub CommandButton1_Click() On Error GoTo ErrorHandler Dim stclname As String Dim stermes As String Dim sh As Worksheet Enterclname: stclname = UCase(InputBox("Enter the Client Surname")) If stclname = "" Then Exit Sub End If For Each sh In ThisWorkbook.Worksheets If UCase(sh.Name) Like stclname & "*" Then sh.Activate Exit Sub End If Next sh Exit_CommandButton1_Click: Exit Sub ErrorHandler: stermes = MsgBox("This worksheet doesn't exist." & Chr(13) & _ "Check the spelling") Resume Enterclname End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
VLOOKUP returns incorrect data | Excel Worksheet Functions | |||
Pmt formula returns incorrect answer | Excel Discussion (Misc queries) | |||
DCount returns incorrect Result | Excel Worksheet Functions | |||
sumif formula returns incorrect value | Excel Worksheet Functions | |||
Vlookup returns incorrect match | Excel Discussion (Misc queries) |