How to Autofill last row with formula, when data is received from IFTTT on the last row?

前端 未结 2 564
庸人自扰
庸人自扰 2021-01-17 08:02

I have a spreadsheet: https://docs.google.com/spreadsheets/d/1df2cp4DsJvSeBvhsNjLgIa5x_RO1X7s_APRdFzU6jqQ/edit?usp=sharing

|    | C                                    


        
2条回答
  •  北荒
    北荒 (楼主)
    2021-01-17 09:08

    This is a very common problem when dealing with auto-inserted data through sheets api or Google forms. The easiest solution would be to convert all your formulas into arrayformulas. For eg, Your formula in D2

    =MID(C2,1,2)&"."&MID(C2,3,2)&".2020
    

    can be modified as

    In D1:

    =ARRAYFORMULA({"Extracted Date";MID(C2:INDEX(C:C,COUNTA(C:C)),1,2)&"."&MID(C2:INDEX(C:C,COUNTA(C:C)),3,2)&".2020"})
    

    OR using regex:

    =ARRAYFORMULA({"Extracted Date";REGEXREPLACE(C2:INDEX(C:C,COUNTA(C:C)),"(\d{2})(\d{2}).*","$1.$2.2020")})
    

    The table then becomes:

    |    | C                               | D                                                                                                                   |
    |----+---------------------------------+---------------------------------------------------------------------------------------------------------------------|
    | 1> | From IFTTT                      | =ARRAYFORMULA({"Extracted Date";MID(C2:INDEX(C:C,COUNTA(C:C)),1,2)&"."&MID(C2:INDEX(C:C,COUNTA(C:C)),3,2)&".2020"}) |
    | 2> | 0809 1800 0909 0600 RLK Steiger |                                                                                                                     |
    | 3> | 0809 1800 0909 0600 RLK Dvorak  |                                                                                                                     |
    | 4> | 0909 0600 0909 1800 UNIS Brando |                                                                                                                     |
    

    Here the rest of D:D is auto filled automatically.

    • We use array literals on the header row: {"Extracted Date";Formula for rest of the column}

    • Whenever a new row comes, INDEX/COUNTA() auto calculates the last row and automatically fills the formula upto last row. See here for a deeper explanation on INDEX/COUNTA.

提交回复
热议问题