Sub DetermineErrMsg()
Dim selr As Integer
selr = Selection.Row
On Error Resume Next
Range("c" & selr) = Range("a" & selr) + Range("b" & selr)
If Err.Number <> 0 Then 'There is an error
If Err.Number = 13 Then
MsgBox "Please type a number in the box"
End If
Else: MsgBox "There is no error"
End If
End Sub
http://s24.postimg.org/ncebpkbwz/excelvba.jpg
Hello everyone! I don't know why excel cannot detect an error when I put texts in Cell A4 and B4. It just returns the combined texts in Cell C4. However, an error can be found when I put a number in Cell A3 and texts in Cell B3. Thanks for your help in advance.
Bookmarks