Hi there,
I'm trying to create a method of preventing people from using my macro on the wrong workbooks and incorrectly named workbooks or sheets.
I have tried:
It always flags the errors though even if there is no error happening. I tried putting the labels at the end of my sub but then they're never flagged!
Can anyone help me out? Ideally I want a message box to flag up with the message telling someone what they did wrong.
Thanks
I'm trying to create a method of preventing people from using my macro on the wrong workbooks and incorrectly named workbooks or sheets.
I have tried:
Code:
[COLOR="Green"]' Error Messages[/COLOR]
ErrMsg11:
MsgBox ("This macro is intended for 'DT Global Orders Incomplete.xlsx'" & vbCrLf & _
"Please ensure that is is named correctly or that you are running the macro on the correct file."), , "Filename Error - You got Schooled!"
ErrMsg12:
MsgBox ("Enter the main sheet is titled:" & vbCrLf & "'DT Global Orders Incomplete'."), , "Wrong Sheet Titles!"
Windows("DT Global Orders Incomplete.xlsx").Activate
[COLOR="Blue"]On Error GoTo[/COLOR] ErrMsg11
Sheets("DT Global Orders Incomplete").Select
[COLOR="blue"]On Error GoTo[/COLOR] ErrMsg12
It always flags the errors though even if there is no error happening. I tried putting the labels at the end of my sub but then they're never flagged!
Can anyone help me out? Ideally I want a message box to flag up with the message telling someone what they did wrong.
Thanks