Manage errors with multiple InPut Boxes

Giganews Newsgroups
Subject: Manage errors with multiple InPut Boxes
Posted by:  L. Howard (lhkitt…@comcast.net)
Date: Mon, 28 Sep 2015

What would be the proper way to manage errors for a multitude of input boxes entering Strings or Longs, boxes have OK, Cancel & Red "X".

Click OK with no entry produces Type Mismatch, as does Cancel.  Or one could enter text in a Long Dimmed input box.

Does it make sense to have a "On Error GoTo" for each input box to go back to the same box with a MsgBox prompt?

Thanks,
Howard

Sub EmployeeDataEnter()

Dim lngLstRow&

Dim EmpID As Long, ContNo As Long, SectNo As Long
Dim strName As String, strEmpTyp As String, strPosTitle _
            As String, strRepoMF As String

EmpID = InputBox("Employee ID No.", "Employee ID")

strName = InputBox("Name:", "Name of racer/owner")

strEmpTyp = InputBox("Type" & vbNewLine & _
            "Full Time" & vbNewLine & _
            "Contract" & vbNewLine & _
            "Other", "Employee Type")

strPosTitle = InputBox("Type:" & vbNewLine & _
              "Worker" & vbNewLine & _
              "Clerical" & vbNewLine & _
              "Exhibition", "Title of Worker:")

strRepoMF = InputBox("Male - Female" & vbNewLine & _
            "Female" & vbNewLine & _
            "Male", "Repo-M/F")

ContNo = InputBox("Employee Contact No.", "Contact")

SectNo = InputBox("Section:", "Section")

' For a date if needed
' strDate = InputBox("Date:", "Date Enter")

' Data from input boxes added to the Master sheet"
With Sheets("Master")
lngLstRow = .UsedRange.Rows.Count + .UsedRange.Row
.Range("A" & lngLstRow).Value = EmpID
.Range("B" & lngLstRow).Value = strName
.Range("C" & lngLstRow).Value = strEmpTyp
.Range("D" & lngLstRow).Value = strPosTitle
.Range("E" & lngLstRow).Value = strRepoMF
.Range("F" & lngLstRow).Value = ContNo
.Range("I" & lngLstRow).Value = SectNo

End With

'Sheets("Sheet1").Select
End Sub

Replies