There must be a better way to code this
You could try this. Its not that much shorter, but its a little easier to
read. Hope this helps! If so, let me know, click "YES" below.
Select Case True
Case error1 < 0 And error2 < 0
MsgBox error1 & " data input are missing and highlighted in
yellow. " _
& error2 & " entries are a missmatch and highlighted in blue."
Exit Sub
Case error1 < 0
MsgBox error1 & " data input are missing and highlighted in
yellow."
Exit Sub
Case error2 < 0
MsgBox error2 & " entries entries are a missmatch and
highlighted in blue."
Exit Sub
Case Else
Exit Sub
End Select
--
Cheers,
Ryan
"Frank" wrote:
I am no VBA pro but I do write several semi complicated macro.
Here is that I wrote to check for two errors using if then else
statements. It works perfectly but I wonder I it could be written more
professionally.
If error1 < 0 Then 'error 1 check
If error2 < 0 Then 'error 1 & 2 found
MsgBox error1 & " data input are missing and highlighted in
yellow. " _
& error2 & " entries are a missmatch and highlighted in blue."
Exit Sub
Else 'error 1 only found
MsgBox error1 & " data input are missing and highlighted in
yellow."
Exit Sub
End If
Else
If error2 < 0 Then 'error 2 only found
MsgBox error2 & " entries entries are a missmatch and
highlighted in blue."
Exit Sub
Else ' no error
Exit Sub
End If
End If
.
|