Forum Discussion

apmulheran's avatar
apmulheran
Copper Contributor
Apr 30, 2020

How to automatically create a variable number of rows on a linked sheet based on criteria

Hi,

 

I am looking for a way to automate some entries my team is making. I am dealing with a one-to-many relationship. Below is a simple example of what I currently have

TABLE 1 - Itineraries 

DateItinerary IDPrimary GuestTotal Number of Guests
4/30/20202154-5255Aldous Huxley5
4/30/20202168-3526Albert Camus3

 

TABLE 2 - Guests 

DateItinerary IDGuest NameAge
4/30/20202154-5255Aldous Huxley47
4/30/20202154-5255Andrea Huxley45
4/30/20202154-5255Betty Huxley20
4/30/20202154-5255Jason Huxley18
4/30/20202154-5255Agnes Huxley68
4/30/20202168-3526Albert Camus54
4/30/20202168-3526Beatrix Camus52
4/30/20202168-3526Guy Camus40

 

My goal: TABLE 1, the user has entered a single and unique Itinerary ID. Associated with that are a number of guests, specified in the 4th column (5 and 3, respectively).

 

I would like  second sheet to also be created with the 1st and 2nd columns' information, and the corresponding number of rows. Essentially, setting up a guest table. So - since Itinerary ID 2168-3526 has 3 guests, the table for guests creates 3 rows. Is this possible?

3 Replies

  • apmulheran 

    I attempted this more as a challenge than anything else.  The output is an Excel Table with conditional formatting to create the borders.  There is an 'almost hidden' column that returns the primary guest name but allows it to overflow into the Guest Name column unless overwritten.  I have used Office 365 using XLOOKUP but I did also implement a solution with VLOOKUP just to remind myself of what a useless function it is!

     

     

  • amit_bhola's avatar
    amit_bhola
    Iron Contributor

    apmulheran , Though with a series of tricky formulas this can be achieved, but i would suggest against it as the formulas are complex to understand and maintain in long term.

    Attached template achieves this for upto 10 guests per 10 entries , transformation is done from Sheet1 to Sheet3 , Sheet2 is used for temporary calculation used to make Sheet3.

    The whole thing breaks down if you rename Sheet2 or insert any rows or columns.

    So as i said, if need is utmost, it can be achieved, but would suggest against it.

Resources