Results 1 to 3 of 3

How to cluster together variables in an IF statement

Threaded View

  1. #1
    Forum Contributor
    Join Date
    09-04-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    298

    How to cluster together variables in an IF statement

    Right now I have:

    IF x = n1 or x = n2 or x = n3 or x = n4 or x = n5 or x = n6 or x = n7 or x = n8 or x = n9 or x = n10 and x <> "" then
    On a userform, there are a bunch of text boxes where you can enter in as many names as you want to search against X.

    For example, you could fill in the first three of the text boxes with "Jim" "John" and "Larry" and n1 would = Jim, n2 = John and n3 = Larry. So basically the formula is checking
    if X = "Jim" OR X = John OR x = Larry.
    What I would ALSO like to do, is have the ability for someone to enter in "James" in one of the text boxes.

    James is the supervisor of Jim, John, and Larry. So I want it to where if you only fill in one text box with the value of "James", the script would automatically have the formula checking to see if X = (Jim, John, or Larry).

    I get that I could just say
    If Textbox1.value = "James" then 
    n1 = "Jim"
    n2 = "John"
    n3 = "Larry"
    but I didn't know if there was an easier way to do this.

    I would like to cluster it even further, to where let's say I have "Alex", who is the boss of James, as well as "Frank".

    I would like entering "Alex" in one of the textboxes to automatically check the names of all subordinates under Frank and James against X. There may be continuing levels to this chain.

    I also would like to group it by department, such as "Finance" would check all the names in the Finance list against X.

    What is the easiest way to accomplish this?
    Last edited by ks100; 10-14-2014 at 11:12 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Set Variables With If Statement
    By w.m.christensen in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-22-2013, 12:10 AM
  2. [SOLVED] IF AND OR Statement with 4 variables
    By Webbers in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-24-2012, 03:03 PM
  3. IF Statement with 3 variables
    By garopro in forum Excel General
    Replies: 11
    Last Post: 09-29-2011, 12:23 PM
  4. Too many variables for an if than statement?
    By repke in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 05-02-2006, 12:01 PM
  5. Use variables in sql statement
    By Markantesp in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-08-2005, 04:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1