ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Single message box for multiple IF statements (https://www.excelbanter.com/excel-programming/284403-single-message-box-multiple-if-statements.html)

simon

Single message box for multiple IF statements
 
I have three separate IF statemnts. Currently when they
are true, the following code is executed:

First IF statement

MsgBox "Please enter a Client Name"
Cancel = True

Second IF statement

MsgBox "Please enter a Sub Client"
Cancel = True

Third IF statement

MsgBox "Please enter a File Barcode"
Cancel = True


This produces three message boxes.

Is it possible to have one message box that shows the
statements that are true.


Lars Kofod

Single message box for multiple IF statements
 
First IF Statement
sText="Please enter a Client Name

2. If Statement
sText="Please enter a Sub Client"

3. IF Statement
sText="Please enter a File Barcode"

msgbox sText
Cancel=true
-----Original Message-----
I have three separate IF statemnts. Currently when they
are true, the following code is executed:

First IF statement

MsgBox "Please enter a Client Name"
Cancel = True

Second IF statement

MsgBox "Please enter a Sub Client"
Cancel = True

Third IF statement

MsgBox "Please enter a File Barcode"
Cancel = True


This produces three message boxes.

Is it possible to have one message box that shows the
statements that are true.

.


Nikos Yannacopoulos[_5_]

Single message box for multiple IF statements
 
Simon,

msg = ""

IF 1st is true then msg = "Please enter a Client Name" &
(chr10)
IF 2nd is true then msg = msg & "Please enter a Sub
Client" & (chr10)
IF 3rd is true then msg = msg & "Please enter a Sub
Client" & (chr10)

msgbox msg

-----Original Message-----
I have three separate IF statemnts. Currently when they
are true, the following code is executed:

First IF statement

MsgBox "Please enter a Client Name"
Cancel = True

Second IF statement

MsgBox "Please enter a Sub Client"
Cancel = True

Third IF statement

MsgBox "Please enter a File Barcode"
Cancel = True


This produces three message boxes.

Is it possible to have one message box that shows the
statements that are true.

.


Tom Ogilvy

Single message box for multiple IF statements
 
Dim msg as String
msg = ""
If criteria1 then msg = msg & "Please enter a Client Name" & vbcrlf
if criteria2 then msg = msg & "Please enter a Sub Client" & vbCrLf
if critiera3 then msg = msg & "Please enter a file BarCode"
if msg < "" then
msgbox msg
End if

--
Regards,
Tom Ogilvy


"Simon" wrote in message
...
I have three separate IF statemnts. Currently when they
are true, the following code is executed:

First IF statement

MsgBox "Please enter a Client Name"
Cancel = True

Second IF statement

MsgBox "Please enter a Sub Client"
Cancel = True

Third IF statement

MsgBox "Please enter a File Barcode"
Cancel = True


This produces three message boxes.

Is it possible to have one message box that shows the
statements that are true.




No Name

Single message box for multiple IF statements
 
this solution worked great.

many thanks.


-----Original Message-----
Dim msg as String
msg = ""
If criteria1 then msg = msg & "Please enter a Client

Name" & vbcrlf
if criteria2 then msg = msg & "Please enter a Sub Client"

& vbCrLf
if critiera3 then msg = msg & "Please enter a file

BarCode"
if msg < "" then
msgbox msg
End if

--
Regards,
Tom Ogilvy


"Simon" wrote in

message
...
I have three separate IF statemnts. Currently when they
are true, the following code is executed:

First IF statement

MsgBox "Please enter a Client Name"
Cancel = True

Second IF statement

MsgBox "Please enter a Sub Client"
Cancel = True

Third IF statement

MsgBox "Please enter a File Barcode"
Cancel = True


This produces three message boxes.

Is it possible to have one message box that shows the
statements that are true.



.



All times are GMT +1. The time now is 07:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com