+ Reply to Thread
Results 1 to 9 of 9

How to align columns

  1. #1
    Registered User
    Join Date
    11-21-2014
    Location
    london
    MS-Off Ver
    mac 2013
    Posts
    7

    How to align columns

    Hi,
    In the attached worksheet, patient data is split into right and left eyes, with the corresponding patient ID number in columns A & F. Instead of right and left, I would like to generate columns labelled 'Worst eye' and 'Best eye,' based on the scores in columns C & H. (A high score = worse score). I think I need to align the ID numbers first, but not sure how to do that.

    '-1' should be blank as this means no score was collected.
    Not all patients had both eyes examined (e.g. patient 16).

    Any suggestions gratefully received.
    Many thanks
    Attached Files Attached Files

  2. #2
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: How to align columns

    I think that this should do what you want.
    Attached Files Attached Files
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: How to align columns

    There's a workbook at https://app.box.com/shared/elrnbidnr7 that will do this (part shown)

    Row\Col
    A
    B
    C
    D
    E
    F
    G
    H
    I
    1
    ID RIGHT EXAM RIGHT SCORE RIGHT SURGERY ID LEFT EXAM LEFT SCORE LEFT SURGERY
    13
    14
    01/27/1992
    6
    14
    01/27/1992
    6
    14
    15
    01/17/1992
    -1
    15
    01/17/1992
    7
    15
    16
    01/09/1992
    6
    16
    17
    08/20/1991
    -1
    17
    08/20/1991
    -1
    17
    19
    01/16/1992
    6
    19
    01/16/1992
    5
    04/16/1991
    18
    20
    01/17/1991
    9
    20
    01/17/1991
    6
    01/01/1979
    19
    22
    01/06/1992
    -1
    09/09/1991
    22
    01/06/1992
    6
    01/23/1991
    20
    27
    04/15/1991
    9
    12/04/1991
    21
    28
    09/06/1989
    9
    09/26/1990
    28
    09/06/1989
    12
    09/20/1989
    22
    29
    05/03/1990
    6
    29
    05/03/1990
    -1
    03/19/1984
    46
    61
    12/22/1988
    4
    61
    12/22/1988
    5
    47
    62
    05/02/1985
    6
    62
    05/02/1985
    9
    48
    63
    01/03/1984
    12
    49
    64
    02/27/1985
    -1
    64
    02/27/1985
    -1
    50
    65
    02/09/1990
    9
    65
    02/09/1990
    -1


    The rows that are hidden above just for compactness will not be hidden in the file.

    Then you can use newdoverman's formulas.
    Last edited by shg; 11-21-2014 at 07:58 PM.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    11-21-2014
    Location
    london
    MS-Off Ver
    mac 2013
    Posts
    7

    Re: How to align columns

    Thanks for the speedy response.
    Not quite the solution I'm after. The problem is that the ID numbers in columns A and F get out of sync, so that the formula in J15 in your file compares the right eye of patient number 17 and the left eye of patient number 16.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: How to align columns

    The workbook at the link aligns those rows.

  6. #6
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: How to align columns

    I don't know why the macro ran that you were given by shg doesn't work correctly. I hope that it can be fixed.

    I used worksheet formulae to solve the problem...I hope.

    I inserted a new column A and inserted the numbers starting at 2 and filled down the column. I then inserted columns to shift the original data over to column T and beyond.

    With the new ID numbers in column A, I used VLOOKUP to find the IDs for both the right and left eyes.

    Sorry for the inconvenience.
    Attached Files Attached Files

  7. #7
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: How to align columns

    I ran the macro by shg with your data without problems...PERFECT

  8. #8
    Registered User
    Join Date
    11-21-2014
    Location
    london
    MS-Off Ver
    mac 2013
    Posts
    7

    Re: How to align columns

    Thank you both. I've not used vlookup before. V useful tool. I have learnt something - much appreciated.

  9. #9
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: How to align columns

    You're welcome. Thank you for the feedback.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Align 3 columns with 2 columns of matching data
    By loritee in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-23-2013, 10:36 AM
  2. Align 3 columns with 2 columns of matching data
    By bearnbillie in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-04-2012, 08:33 AM
  3. Formula to align two columns with nearly similar text and attached numeric columns
    By Benefits Recon in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-27-2012, 12:03 AM
  4. right align columns
    By stermann in forum Excel General
    Replies: 2
    Last Post: 08-15-2007, 06:05 AM
  5. How to align entries in columns so other columns will follow ?
    By Artur in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-07-2005, 04:15 AM

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