Results 1 to 10 of 10

Adding record above the next line based on conditions. VBA required?

Threaded View

  1. #1
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    513

    Adding record above the next line based on conditions. VBA required?

    Hi,

    Wondering if anybody can assist. I have attached the Excel file.

    The original worksheet shows the original data arrangement, and the desired output is the final output.


    The logic is....whenever the break down necessary column shows a y in the original worksheet, we need to add a row ABOVE.

    As you can see, the first row in the desired output sheet remains the same. On the added line as you can see, the start_date becomes the end_date of the previous line, and its end_date is whenever the original end_date was. On the 3rd line, the start_date and end_date is the same in this case. All three lines will have the same admission_date assigned. We get 60 for the days_counted because it's just the subtraction of start_date from end_date.

    I know it may seem redundant the way that record needs to be inserted, but it will satisfy our reporting standard.

    Anyone able to assist? Can this be done in Excel or with some VBA? The actual worksheet would have many patient records, each identified by a unique patient ID. I would like to do this for each patient. So, it has to first check if two records belong to the same patient. (i.e. it has to be all 2, or all 3, or all 4).

    Is this clear?

    Thank you
    Attached Files Attached Files

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