ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   If / And / Or Macro (https://www.excelbanter.com/excel-worksheet-functions/172385-if-macro.html)

Graeme

If / And / Or Macro
 
Basic question: I am trying to write a macro that looks to see whether A1 =
"X" and also if any of A2...10 = "Y", then Statement A, else Statement B.
Thank you in advance.

Mike H

If / And / Or Macro
 
Try this

=IF(AND(A1="x",COUNTIF(A2:A10,"y")0),"Statement A","Statement B")

Mike

"Graeme" wrote:

Basic question: I am trying to write a macro that looks to see whether A1 =
"X" and also if any of A2...10 = "Y", then Statement A, else Statement B.
Thank you in advance.


Graeme

If / And / Or Macro
 
Mike - thanks for the quick response. I see how this would work as an excel
formula, but if it's a line of code in a macro, does it need to be expressed
differently? thanks.

"Mike H" wrote:

Try this

=IF(AND(A1="x",COUNTIF(A2:A10,"y")0),"Statement A","Statement B")

Mike

"Graeme" wrote:

Basic question: I am trying to write a macro that looks to see whether A1 =
"X" and also if any of A2...10 = "Y", then Statement A, else Statement B.
Thank you in advance.


Tyro[_2_]

If / And / Or Macro
 
Please state your question in the context of its environment. Don't waste
our time.

Tyro

"Graeme" wrote in message
...
Basic question: I am trying to write a macro that looks to see whether A1
=
"X" and also if any of A2...10 = "Y", then Statement A, else Statement B.
Thank you in advance.





All times are GMT +1. The time now is 02:06 AM.

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