Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Jan 21, 1:56*pm, Per Jessen wrote:
Hi The exit sub statements are not needed, as the code will terminate after all. Look at this: Sub aaa() If error1 < 0 And error2 < 0 Then 'error 1 & 2 found 'error 1 check * * MsgBox error1 & " data input are missing and highlighted in yellow. " _ * * & error2 & " entries are a missmatch and highlighted in blue." ElseIf error1 < 0 Then 'error 1 only found * * MsgBox error1 & " data input are missing and highlighted in yellow." ElseIf error2 < 0 Then *'error 2 only found * * MsgBox error2 & " entries entries are a missmatch and highlighted in blue." End If End Sub Regards, Per On 21 Jan., 22:01, 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- Hide quoted text - - Show quoted text - Thanks. Not familiar with elseif but it looks very simple! |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
split post code (zip code) out of cell that includes full address | Excel Discussion (Misc queries) | |||
How can I modify my code to offset the defined range and repeat theprocedure instead of duplicating my code? | Excel Programming | |||
Run VBA code only worksheet change, but don't trigger worksheet_change event based on what the code does | Excel Programming | |||
Shorten code to apply to all sheets except a few, instead of individually naming them, and later adding to code. | Excel Programming | |||
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... | Excel Programming |