Forum Discussion

Bonita's avatar
Bonita
Copper Contributor
Oct 22, 2024

Insert a group of rows (copy) from one tab into another tab based on a cell value

Dear experts,

Please put me out of my misery.  After a long process of pulling data from a PDF to put into Excel, I now have 2 tabs of data. It was beautiful and served the purposes initially explained.  Since then, more requirements have surfaced and I also need to track status. 

 

I'm providing an simplified example to protect the sensitivity of the real data.  

 

Offices tab

OfficeAsset Set
11
22
31

 

Assets tab

Asset SetAssetDescriptionDelivery DateDelivered?
1L-shaped DeskIkea 1003  
1Ergo ChairWayfair 40  
1BookshelfIkea 502  
2Basic DeskWalmart 20-7474  
2Basic ChairWalmart 20-9348  
2

Bookshelf

Ikea 502

  

 

Data is in a single Excel worksheet. One tab contains all the offices in a building. The second tab contains the breakdown of items that belong in that office. I made sure to have the Asset number relationship in the tabs because I'm pulling this data into a different format for use elsewhere.

(Side note: the items that make up an asset set could exist in another asset set.; see Bookshelf) 

 

I add 2 new columns in the Assets tab for Delivery info since I need to know whether the item was delivered to the office, for all items, for all offices. 

 

I can do the Index Match formula to find the Asset Set value in the Offices tab but I couldn't find any way to select all the rows in the Asset tab, Copy, and Insert Copied Rows under that referenced row on the Offices tab. 😕  I don't know VBA or Macros except to copy and tweak.

 

I have 1000 rows in the Assets tab and 300 rows in the Offices tab.  I really really don't want to do this manually if I can avoid it.  I'll need to do this as more office buildings get updated equipment.

 

In the meantime, I will start this process manually;

  1. Create a new tab
  2. Copy Office row, paste into new sheet
  3. Copy group of rows from Asset tab
  4. paste under office row (starting at column B to preserve the column heading detail)
  5. Rinse and repeat.

 

I hope someone has an amazing solution. Thanks in advance for your brain.

 

 

  • Bonita 

    =DROP(IFNA(REDUCE("",SEQUENCE(ROWS(A3:A5)),LAMBDA(u,v,VSTACK(u,"Office "&INDEX(A3:A5,v),HSTACK("Asset Set","Asset","Description","Delivery Date","Delivered?"),FILTER(A9:E14,A9:A14=INDEX(B3:B5,v))))),""),1)

     

    With Office 365 or Excel for the web you can apply this formula.

  • Bonita 

    =DROP(IFNA(REDUCE("",SEQUENCE(ROWS(A3:A5)),LAMBDA(u,v,VSTACK(u,"Office "&INDEX(A3:A5,v),HSTACK("Asset Set","Asset","Description","Delivery Date","Delivered?"),FILTER(A9:E14,A9:A14=INDEX(B3:B5,v))))),""),1)

     

    With Office 365 or Excel for the web you can apply this formula.

    • Bonita's avatar
      Bonita
      Copper Contributor
      Thank you so much!! I would have never figured it out.
  • peiyezhu's avatar
    peiyezhu
    Bronze Contributor

    Bonita 

     

    sql:

    select * from Sheet5 limit 20;
    select * from Sheet4 limit 20;
    create temp table aa as
    select * from Sheet4 join Sheet5 using(`Asset Set`);
    select Office,group_concat(Asset Set||Asset||Description) 子表 from aa group by Office;

     

Resources