This is an example of a message presented in the event of an error being raised in the ‘NEW_Procedure’ procedure.
Please edit to suit your requirements.
Author: michael@excelexperts.co.uk
Sub errortrap(strMod As String, strSub As String, Optional iline As Integer) Dim linenumbermsg As String If iline = 0 Then linenumbermsg = "" Else linenumbermsg = "Line" & vbTab & " : " & CStr(iline) End If ActiveSheet.Activate Call MsgBox("An error has been detected in the following:" _ & vbCrLf & "" _ & vbCrLf & "Module" & vbTab & " : " & strMod _ & vbCrLf & "Sub" & vbTab & " : " & strSub _ & vbCrLf & linenumbermsg _ & vbCrLf & "" _ , vbInformation, "Warning") End Sub