1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Excel Macro - 0 < X < 10

Discussion in 'Business Applications' started by CWDENVER, Feb 7, 2007.

Thread Status:
Not open for further replies.
Advertisement
  1. CWDENVER

    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.
     
  2. OBP

    OBP

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

    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.
     
  4. Zack Barresse

    Zack Barresse

    Joined:
    Jul 25, 2004
    Messages:
    5,452
    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
     
  5. OBP

    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
     

    Attached Files:

    • test.xls
      File size:
      20.5 KB
      Views:
      298
  6. Sponsor

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 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/542027

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice