+ Reply to Thread
Results 1 to 17 of 17

If name in A1 make A3 show "1"

  1. #1
    Forum Contributor
    Join Date
    11-11-2007
    Posts
    263

    Post If name in A1 make A3 show "1"

    I am attempting to get a nested if loop to work in Excel but I am running into the dreaded #NAME error.

    Here is what I am doing.

    In Column A I have lets say three names repeat in various orders.

    Moe A
    Larry B
    Curly C

    What I want to do in Column C is show if Moe A, show 1, Larry B, show 2, Curly C, show 3.

    So at the end I will have a mix of 1,2,3,3,2,2,1,1,1,1,2, going down column C.

    How do I get this to work? I ultimately have it where there are over 80 individual names, but there are over 250 entries. Can someone please help me figure this out?
    Last edited by NBVC; 03-07-2012 at 02:42 PM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: If name in A1 make A3 show "1"

    Are you just looking to assign each person a number based on first one being assigned a 1?

    If so, and assuming your names are starting in A2, then in B2:

    =IF(COUNTIF($A$1:A2,A2)>1,VLOOKUP(A2,A$1:B1,2,0),MAX(B$1:B1)+1)

    copied down.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: If name in A1 make A3 show "1"

    Or maybe this, if there are only three names?
    Please Login or Register  to view this content.
    Last edited by Marcol; 03-06-2012 at 03:29 PM.
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: If name in A1 make A3 show "1"

    OP did mention:

    I ultimately have it where there are over 80 individual names

  5. #5
    Forum Contributor
    Join Date
    11-11-2007
    Posts
    263

    Re: If name in A1 make A3 show "1"

    Quote Originally Posted by NBVC View Post
    Are you just looking to assign each person a number based on first one being assigned a 1?

    If so, and assuming your names are starting in A2, then in B2:

    =IF(COUNTIF($A$1:A2,A2)>1,VLOOKUP(A2,A$1:B1,2,0),MAX(B$1:B1)+1)

    copied down.
    Actually it is A1, A2, A3, etc for the names.

    C1, C2, C3, etc are where the numbers will go.

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: If name in A1 make A3 show "1"

    So after 26 unique names you start at B1, etc...?

  7. #7
    Forum Contributor
    Join Date
    11-11-2007
    Posts
    263

    Re: If name in A1 make A3 show "1"

    Quote Originally Posted by NBVC View Post
    So after 26 unique names you start at B1, etc...?

    No, Column B has other info in it.

  8. #8
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: If name in A1 make A3 show "1"

    I am not following, can you post a sample workbook showing various names and what you want to see in adjacent column?

  9. #9
    Forum Contributor
    Join Date
    11-11-2007
    Posts
    263

    Re: If name in A1 make A3 show "1"

    Sure, here is the script.
    Attached Files Attached Files

  10. #10
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: If name in A1 make A3 show "1"

    Yes, but what is supposed to be filled into those 2 blank columns?

  11. #11
    Forum Contributor
    Join Date
    11-11-2007
    Posts
    263

    Re: If name in A1 make A3 show "1"

    I figured that would be obvious by the titles... sorry.

    The first blank is what the company does, genetic testing, etc... I took it out because honestly it's a need to know basis.
    The second blank is the ID, so starting at 1, going down to the end. Hence the need for the script. But the problem comes in that if there is going to be more than one line with the same name, how is it going to be identified by your script as already given a number?

  12. #12
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: If name in A1 make A3 show "1"

    What I don't know is what kind of coding do you want to give the ID. If it is simply a number, so that all Stapla get a 1, all Perkin Elemer get a 2, all Biogen Idec get a 3, etc... then I gave you that formula (you just need to adjust for the extra column):

    =IF(COUNTIF($A$1:A2,A2)>1,VLOOKUP(A2,A$1:C1,3,0),MAX(C$1:C1)+1)

    If you don't want just a number, it might be more complicated, and we need to know some sample code you need to use as the company id.

    if the company listing is only unique companies, and no duplicates, then:

    =ROWS($A$2:$A2)

    and if you want a generic code like Company1, Company2, etc, then try:

    ="Company"&ROWS($A$1:$A1) copied down

    or

    ="Company"&TEXT(ROWS($A$1:$A1),"000")

    if you want like: Company001, Company002, ... Company999...
    Last edited by NBVC; 03-06-2012 at 05:26 PM.

  13. #13
    Forum Contributor
    Join Date
    11-11-2007
    Posts
    263

    Re: If name in A1 make A3 show "1"

    Quote Originally Posted by NBVC View Post
    What I don't know is what kind of coding do you want to give the ID. If it is simply a number, so that all Stapla get a 1, all Perkin Elemer get a 2, all Biogen Idec get a 3, etc... then I gave you that formula (you just need to adjust for the extra column):

    =IF(COUNTIF($A$1:A2,A2)>1,VLOOKUP(A2,A$1:C1,3,0),MAX(C$1:C1)+1)

    If you don't want just a number, it might be more complicated, and we need to know some sample code you need to use as the company id.

    if the company listing is only unique companies, and no duplicates, then:

    =ROWS($A$2:$A2)

    and if you want a generic code like Company1, Company2, etc, then try:

    ="Company"&ROWS($A$1:$A1) copied down

    or

    ="Company"&TEXT(ROWS($A$1:$A1),"000")

    if you want like: Company001, Company002, ... Company999...
    What I'm looking for is this:

    In Column A you get the companies, such as you shown. In Column C you get their IDs, If I have to I will do a reference from another sheet if I need to. Here is a better concept of what I need.

    Of course I am going to have to make it so that if there is nothing in the name field no ID # will show up either.

    I think I may of answered my own question, I probably will have to create a reference loop, but I may be wrong.

    Tab 1 has the log, tab 2 has the names with their identifiers. What I want is that when a name in Column A typed in, it is referenced by the other tab. Then outputs the correct number, if none is available it shows a blank field. Does this make any sense?
    Attached Files Attached Files

  14. #14
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: If name in A1 make A3 show "1"

    That's better

    You never stipulated that you had a lookup table.....

    Anyhoot... in C2 enter formula:

    =IFERROR(VLOOKUP(A2,'Individial Companies'!$A$1:$B$84,2,FALSE),"")

    and copy it down.

  15. #15
    Forum Contributor
    Join Date
    11-11-2007
    Posts
    263

    Re: If name in A1 make A3 show "1"

    Quote Originally Posted by NBVC View Post
    That's better

    You never stipulated that you had a lookup table.....

    Anyhoot... in C2 enter formula:

    =IFERROR(VLOOKUP(A2,'Individial Companies'!$A$1:$B$84,2,FALSE),"")

    and copy it down.
    Thanks, but I have a question, is there a reason you put a limitation on here? $B$84 wouldn't it be better to have an open ended option just in case more companies are added in later on?

    Something like: =IFERROR(VLOOKUP(A2,'Individial Companies'!$A$1:$B,2,FALSE),"")

    Or am I oversimplifying things?

  16. #16
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: If name in A1 make A3 show "1"

    No, you can do that... sometimes people have other data beneath lookup tables or just want defined ranges...

  17. #17
    Forum Contributor
    Join Date
    11-11-2007
    Posts
    263

    Re: If name in A1 make A3 show "1"

    Not in this case, this is going to be a very simple list, thanks for the help, I'll be asking more if I need any more help

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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