ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Multiple tests for a condition (https://www.excelbanter.com/excel-programming/349474-multiple-tests-condition.html)

Matilda

Multiple tests for a condition
 
Dear All,

I want to execute a statement if two cells meet the same condition (ie not
empty).

Basically, I want the vba syntax for the formula

if(or(A1, B1, <""), doThing, doNoThing)

Many TIAs

Matilda

Dave Peterson

Multiple tests for a condition
 
=if(and(a1<"",b1<""),"dothing", "donothing")

Matilda wrote:

Dear All,

I want to execute a statement if two cells meet the same condition (ie not
empty).

Basically, I want the vba syntax for the formula

if(or(A1, B1, <""), doThing, doNoThing)

Many TIAs

Matilda


--

Dave Peterson

Matilda

Multiple tests for a condition
 
Thanks Dave, but I want to put the test in a vba sub, in an if...then...else
statement. Sorry if I did not make myself clear.

I tried concocting something like that statement , which I would put in a
formula, and got error messages I couldn't interpret.

Matilda



"Dave Peterson" wrote:

=if(and(a1<"",b1<""),"dothing", "donothing")

Matilda wrote:

Dear All,

I want to execute a statement if two cells meet the same condition (ie not
empty).

Basically, I want the vba syntax for the formula

if(or(A1, B1, <""), doThing, doNoThing)

Many TIAs

Matilda


--

Dave Peterson


Gordon Rainsford[_3_]

Multiple tests for a condition
 
Matilda wrote:

Dear All,

I want to execute a statement if two cells meet the same condition (ie not
empty).

Basically, I want the vba syntax for the formula

if(or(A1, B1, <""), doThing, doNoThing)

Many TIAs

Matilda


If Not IsEmpty(Range("a1")) Then
If Not IsEmpty(Range("b1")) Then
dostuff
End If
End If


--
Gordon Rainsford

London UK

Matilda

Multiple tests for a condition
 
A simple nested if! Negated.

Didn't occur to me... thanks Gordon!

"Gordon Rainsford" wrote:

Matilda wrote:

Dear All,

I want to execute a statement if two cells meet the same condition (ie not
empty).

Basically, I want the vba syntax for the formula

if(or(A1, B1, <""), doThing, doNoThing)

Many TIAs

Matilda


If Not IsEmpty(Range("a1")) Then
If Not IsEmpty(Range("b1")) Then
dostuff
End If
End If


--
Gordon Rainsford

London UK



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

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