+ Reply to Thread
Results 1 to 3 of 3

Create code for a new field to return different values depending on existing data.

  1. #1
    Registered User
    Join Date
    05-30-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    16

    Create code for a new field to return different values depending on existing data.

    Hi everyone, I was hoping someone could help me with the following:

    I have a large set of data for patients. One of the fields is for Patient-ID(########), another field is for Case-ID(########), and another field is for Date(DD-MMM-YY).
    Each Patient-ID can occur more than once, each Case-ID can occur more than once, and each Date can occur more than once.

    I need to create a new field for which the possible values are 1, 2, 3, 4, .... I want the default value in this field to be 1 for each row, and I want the value 2 to be displayed for any entries where the Case-ID for a given Patient-ID is different from the first Case-ID for that Patient-ID. And I want the value 3 to be displayed for any entries where the Case-ID for a given Patient-ID is different from the first and second unique Case-IDs for that Patient-ID.

    For example, if for Patient-00384759 I have:

    __Patient-ID__|__Case-ID__|__Date__

    __00384759__|_00239485_ |_26-Jan-12__
    __00384759__|_00239485_ |_13-Feb-12__
    __00384759__|_00239485_ |_25-Feb-12__
    __00384759__|_01392345_ |_30-Mar-12__
    __00384759__|_01392345_ |_09-Apr-12__
    __00384759__|_00897273_ |_27-Jun-12__


    then I want to create a new field such that the data looks like:

    __Patient-ID__|__Case-ID__|___Date____ |__Admission__

    __00384759__|_00239485_ |_26-Jan-12__|_____1_____
    __00384759__|_00239485_ |_13-Feb-12__|_____1_____
    __00384759__|_00239485_ |_25-Feb-12__|_____1_____
    __00384759__|_01392345_ |_30-Mar-12__|_____2_____
    __00384759__|_01392345_ |_09-Apr-12__|_____2_____
    __00384759__|_00897273_ |_27-Jun-12__|_____3_____



    Does anyone know how I'd be able to make the code for this new field? Any help is much appreciated!

    -Niraj

  2. #2
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: Create code for a new field to return different values depending on existing data.

    Put this in a standard module.
    Please Login or Register  to view this content.
    David
    (*) Reputation points appreciated.

  3. #3
    Registered User
    Join Date
    05-30-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Create code for a new field to return different values depending on existing data.

    Thanks a lot David!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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