+ Reply to Thread
Results 1 to 10 of 10

Numbering column B if column A and B follow a pattern

  1. #1
    Registered User
    Join Date
    03-26-2012
    Location
    Houston
    MS-Off Ver
    Excel 2003
    Posts
    17

    Numbering column B if column A and B follow a pattern

    Hey guys,

    I had another question. I have this series as illustrated in the attachment.

    I have these ID numbers in Column A which relate to Column B not in a specific way-but it just represents the occurrence of a particular episode. So most of the ID numbers in Column A have one episode number(column B) but not all. For example, the ones highlighted have the same ID number with two different episode numbers-I just need to name it as 1 if it is only 1 episode number and 2 if it is the second episode number for a particular ID number in Column C.

    I hope I have expressed myself with clarity-please let me know if what I m saying is not very clear. Would greatly appreciate your help as always.

    Thanks.
    Attached Files Attached Files
    Last edited by hbangalore; 04-06-2012 at 09:50 AM.

  2. #2
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Numbering column B if column A and B follow a pattern

    Hi

    Give a try to this formula, in C2 and copy down.

    =B2&" -"&SUMPRODUCT(($A2:$A$1526=A2)*($B2:$B$1526=B2))

    Note: Or this.

    =IF(SUMPRODUCT(($A2:$A$1526=A2)*($B2:$B$1526=B2))=1;B2;B2&" -"&SUMPRODUCT(($A2:$A$1526=A2)*($B2:$B$1526=B2)))
    Last edited by Fotis1991; 04-06-2012 at 10:06 AM. Reason: Note:
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  3. #3
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Numbering column B if column A and B follow a pattern

    advance filter column a&b on unique values.copy to another location pick f1
    once done
    put in h1
    =COUNTIF($F2:F$2,F2) and drag down
    Attached Files Attached Files
    Last edited by martindwilson; 04-06-2012 at 10:15 AM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  4. #4
    Registered User
    Join Date
    03-26-2012
    Location
    Houston
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Numbering column B if column A and B follow a pattern

    Hi Fotis,

    Thanks a lot. the first one works well, the second one is showing an error and is not working.

    The first one is fantastic but it would be great if 1. the sequence of numbers is in order as in 1,2,3 rather than 3,2,1 as this column is in turn related to some values which are time specific and cannot be numbered the other way round and 2. if they just have 1,2,3 rather than xxxxxxx-1,xxxxxxx-2,xxxxxx-3 etc. it would be ideal.

    Thanks Martin, your formula works but it eats up some cases.

    I would have taken years to do this stuff! Thanks again.

  5. #5
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Numbering column B if column A and B follow a pattern

    Hi

    Second formula, works ok and i think it's better than first, but yoy know better, your needs.

    For your first question, i'll take a look, but ...i don't think so..

    For your second, i don't understand, what you mean

    Maybe, show me in your workbook..

    Note:AAAAAAA.....I think, understand. See this...

    =IF(SUMPRODUCT(($A2:$A$1526=A2)*($B2:$B$1526=B2))=1,B2,SUMPRODUCT(($A2:$A$1526=A2)*($B2:$B$1526=B2)))
    Attached Files Attached Files
    Last edited by Fotis1991; 04-06-2012 at 10:53 AM. Reason: Note:

  6. #6
    Registered User
    Join Date
    03-26-2012
    Location
    Houston
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Numbering column B if column A and B follow a pattern

    Hi again,

    May be it is easier if I express it this way-as in the new attachment.

    Column A-case number(nominal)
    Column B-Episode number(nominal)
    Column C-a particular test performed which is numbered as 1,2,3,...based on the number of times it has occurred for a particular case
    (column A)
    Column D-what I want is exactly like column C but some cases as highlighted, have 2 episodes(column B) and hence need to start from 1 again.

    I think there are like 500-600 such occurrences in 6000 or so cases, so not ideal to do it manually!

    Thanks again.
    Attached Files Attached Files

  7. #7
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Numbering column B if column A and B follow a pattern

    ..I had something in my mind, but i can not do it to work...Sorry!

    If you don't find your solution, i promise to take a look again Tomorrow morning....

  8. #8
    Registered User
    Join Date
    03-26-2012
    Location
    Houston
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Numbering column B if column A and B follow a pattern

    thanks. will keep a look out

  9. #9
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Numbering column B if column A and B follow a pattern

    ok this gives result you asked for,i think you have an error at rows 13,14,15
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    03-26-2012
    Location
    Houston
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Numbering column B if column A and B follow a pattern

    Thanks Martin. There was an error as you pointed out. Apologies for the delay in the reply-I was away.

+ 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