Search code examples
google-sheetsgoogle-sheets-querygoogle-sheets-macros

Copy cell data to second sheet based on matching data


I want to use data from a Google Form (Sheet 1) that is collecting in and out times and locations. I would like them in and out submission consolidated on a second sheet (Sheet 2) the end product. If email and date match place them in and out time stamp on a second sheet to be used for additional calculations and viewing. There are several examples out there and things that I have tried but nothing that I can find. This may not be possible in the current format if additional data is needed to filter it can be added. Thanks for the help in advance.

Sheet 1

        A                    B              C                     D
    Timestamp              Email        Going to               Out/In
1/29/2019 16:06:42    [email protected]      Locker                  Out
1/29/2019 16:06:58    [email protected]                              In
1/29/2019 16:13:32    [email protected]     Bathroom                 Out
1/29/2019 16:14:35    [email protected]     Bathroom                 Out
1/29/2019 16:13:48    [email protected]                              In
1/29/2019 16:20:00    [email protected]                              In

Sheet 2

 A               B                  C                          D
Email           Went to             Out                         In
[email protected]   Locker      1/29/2019 16:06:42      1/29/2019 16:10:58
[email protected]   Bathroom    1/29/2019 16:13:32      1/29/2019 16:23:48
[email protected]   Bathroom    1/29/2019 16:14:35      1/29/2019 16:20:00

Solution

  • ={"Email", "Went to", "In", "Out"; 
     {QUERY('Sheet 1'!A2:D, 
      "select B, C, A where C is not null and not D contains 'In'", 0), 
      ARRAYFORMULA(VLOOKUP(QUERY('Sheet 1'!A2:D, 
      "select A where C is null and D contains 'In'", 0), 'Sheet 1'!A2:D, 1, 0))}}
    

    enter image description here