LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF Function error #VALUE Pat[_7_] Excel Worksheet Functions 1 December 6th 11 10:35 PM
Function error Rosemary Excel Worksheet Functions 8 October 20th 06 09:50 AM
3D Function Error srpettew Excel Discussion (Misc queries) 2 April 18th 06 09:48 PM
IF function with #N/A error Roccobarocco Excel Worksheet Functions 4 December 5th 04 08:59 PM
#Name error for VBA function William Ladd Excel Programming 1 October 9th 03 07:19 PM


All times are GMT +1. The time now is 09:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"