ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   If..then statement (https://www.excelbanter.com/excel-discussion-misc-queries/16506-if-then-statement.html)

sheila_d_pratt

If..then statement
 
Hi,

I have the following If statement;

If query ID = "SAPBEXq0002" Then
I want to add another query ID to this statement. I have tried separating
them by a comma and got an error. e.g. If query ID = "SAPBEXq0002",
"SAPBEXq006" Then.

What is the best way to write this so that either query can be used.

Thanks
--
sheila

Chip Pearson

Sheila,

Use code similar to the following:

If queryID = "SAPBEXq0002" Or queryID = "SAPBEXq006" Then


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"sheila_d_pratt" wrote
in message
...
Hi,

I have the following If statement;

If query ID = "SAPBEXq0002" Then
I want to add another query ID to this statement. I have tried
separating
them by a comma and got an error. e.g. If query ID =
"SAPBEXq0002",
"SAPBEXq006" Then.

What is the best way to write this so that either query can be
used.

Thanks
--
sheila




sheila_d_pratt

Thanks for your help Chip!

"sheila_d_pratt" wrote:

Hi,

I have the following If statement;

If query ID = "SAPBEXq0002" Then
I want to add another query ID to this statement. I have tried separating
them by a comma and got an error. e.g. If query ID = "SAPBEXq0002",
"SAPBEXq006" Then.

What is the best way to write this so that either query can be used.

Thanks
--
sheila



All times are GMT +1. The time now is 09:12 PM.

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