Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
On Error function
Why does the On Error function only work when there is
one error? See code below which produces a subscript error for b14 if value is entered incorrectly more than once. Why doesn't "wrongteam" error loop keep running until b14 is entered correctly? Private Sub CommandButton1_Click() Dim TargRange As Range Dim UTeamName Range("b14:b32").ClearContents Range("a1").Select REDO: Range("b14").Value = InputBox("Team Name?", "Enter") UTeamName = Range("b14").Value On Error GoTo WrongTeam Set TargRange = ThisWorkbook.Sheets(UTeamName).Range ("a2") WrongTeam: Msg = "Team Name does not exist, please re-enter" ' this defines the message Style = vbOKCancel ' this defines the answer buttons Title = "Data Entry Error" ' this is message box title Response = MsgBox(Msg, Style, Title) GoTo REDO |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
On Error function
see help on the resume command. Once an error occurs, you are in error
handling mode. If another error occurs in error handling mode, then Excel gives up. Since you never use the resume command, you never leave error handling mode. -- Regards, Tom Ogilvy Tom Donino wrote in message ... Why does the On Error function only work when there is one error? See code below which produces a subscript error for b14 if value is entered incorrectly more than once. Why doesn't "wrongteam" error loop keep running until b14 is entered correctly? Private Sub CommandButton1_Click() Dim TargRange As Range Dim UTeamName Range("b14:b32").ClearContents Range("a1").Select REDO: Range("b14").Value = InputBox("Team Name?", "Enter") UTeamName = Range("b14").Value On Error GoTo WrongTeam Set TargRange = ThisWorkbook.Sheets(UTeamName).Range ("a2") WrongTeam: Msg = "Team Name does not exist, please re-enter" ' this defines the message Style = vbOKCancel ' this defines the answer buttons Title = "Data Entry Error" ' this is message box title Response = MsgBox(Msg, Style, Title) GoTo REDO |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
IF Function error #VALUE | Excel Worksheet Functions | |||
Function error | Excel Worksheet Functions | |||
3D Function Error | Excel Discussion (Misc queries) | |||
IF function with #N/A error | Excel Worksheet Functions | |||
#Name error for VBA function | Excel Programming |