Consulting

Results 1 to 6 of 6

Thread: Solved: Select Cases using two columns

  1. #1
    VBAX Newbie
    Joined
    Aug 2007
    Posts
    3
    Location

    Solved: Select Cases using two columns

    I am a novice and I am trying to use VBA to compare two columns (cell by cell) and place a number in the third column. I am transferring a large number of employees (approx 6000) between companies and need to select the new benefits packages the employees are to recieve in the new company.

    I have tried IF statements and Select Case, to no avail. I have attached a file with a sample of data.

    Written out, what I am attempting to do is: (see attached file)

    IF Column F = ESI AND Column G = EQN THEN column H would be "1"

    I believed that this was an easy Select Case but I can't get it to work when comparing TWO columns and placing a number in a third column!

    Any advice to get me "jump started" on writing a select case statement would be greatly appreciated!

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Use a formula

    =IF(AND(F2="ESI",G2="EQN"),1,"")
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Oct 2005
    Posts
    26
    Location
    Hi sdownes1,

    Try :
    Formula in H2.

    IF(AND(F2="ESI",G2="EQN"),1,"")

    and copy down
    Last edited by benny; 09-25-2008 at 09:23 AM.

  4. #4
    VBAX Newbie
    Joined
    Aug 2007
    Posts
    3
    Location
    Thanks very much!
    But I have multiple combinations, for example, F2 = "ENOI" and G2 = "EQL" which would = 3 in H1, would I need to nest all the variations in the formula or is there an other way

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    best way would be to build a table with all combinations, say

    ESIEQN 1
    ENOIEQL 3
    etc, in say K & L and use

    =IF(ISNA(VLOOKUP(F2&G2,$K$1:$L$10,2,FALSE)),"",VLOOKUP(F2&G2,$K$1:$L$10,2,F ALSE))

    There is a space that gets injected into the second false, remove that.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    VBAX Newbie
    Joined
    Aug 2007
    Posts
    3
    Location
    XLD - That is great! I appreciate the assistance! I have been banging my head against the wall for weeks! I truly appreciate it!

Posting Permissions

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