Excel Macro - 0 < X < 10

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

CWDENVER

Thread Starter
Joined
Dec 1, 2006
Messages
38
I'm trying to use an if statement and I can't get Excel to recognize a formula similar to above. I need it to read if this range is greater than value A AND less than value B, then do this. How do I get the if statement to recognize two constraints? Is there a "between" function? I've searched all over the help file and I can't make it work. Please help. Thanks.
 

OBP

Joined
Mar 8, 2005
Messages
19,895
Try Nesting the If statements ie.
if(a>x,if(a<b,do whatever),"")
 

CWDENVER

Thread Starter
Joined
Dec 1, 2006
Messages
38
That's my fault for not clarifying. I actually need to run this kind of statement in a macro format, not actually in the cell.
 
Joined
Jul 25, 2004
Messages
5,458
Code:
If myVariable > 0 And myVariable < 10 Then
    'passed test
Else
    'did not pass test
End If

'... or ...

If myVariable > 0 Then
    If myVariable < 10 Then
        'passed both tests
    Else
        'passed first test only
    End If
Else
    'did not pass first test
End If
HTH
 

OBP

Joined
Mar 8, 2005
Messages
19,895
As I am not sure if you want to use Excell Cells in the checks or Visual Basic Variables I hva e used both versions.
You can change the Cell values to test it, but you will have to go in to the Macro to change the variables.
To run the macro press Ctrl + a
 

Attachments

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Top