如何在 Google Sheet 中的特定列的输入中添加和突出显示行

How to add and highlight rows on input of particular column in Google Sheet

附件中googlesheet.

Google Sheet - https://docs.google.com/spreadsheets/d/1KxqaI-GYWur0Knt_bShI0GURucqU_cawu_sCoG_8Xlc/edit?usp=sharing

我需要对输入执行以下两个操作。

  1. 如果任何用户在 K 列中将值设为 1,则添加与 ID 相同数量的行。

例如,如果我在 K 列中为 ID = ID_3 输入 1,其中有 5 行,我想在 ID_3 的最后一个实例下方追加这五行并且在附加行中,所有值都应与 ID_3 相同,除了 C 列现在为 ID_3_Append,K 列和 O 列对于附加行应为空白。

  1. 如果有人在 M 列中输入值 1,我们需要检查它属于哪个 ID 并在 E、F 和 G 列中查找该 ID 并突出显示行红色,如果 ID 用户提供的输入为 1,则在 E、F 和 G 列中可用。

  2. 如果有人在更改类型中将值添加为 1,我需要将 Test_1 sheet 中的列 B 更新为 I 从 Put_list 但想要保持公共 ID 的 Mark Status(如果它有任何 Mark Status) between earlier Test_1andPut_list` 不变。此外,我们需要相应地突出显示依赖行。

将 B 列更新为 I 后,我们需要将名称从 'Call' 更改为 'Put'。

这可能会回答您问题的第二部分。 Select 您想要红色条件格式的行范围,例如示例 sheet 中的 A2:A12。 Select格式-条件格式,验证范围,应用自定义公式,如下:

=OR(
  IF($E2<>"NA",IFERROR(MATCH($E2,FILTER($C:$C,$M:$M=1),0)),0),
  IF($F2<>"NA",IFERROR(MATCH($F2,FILTER($C:$C,$M:$M=1),0)),0),
  IF($G2<>"NA",IFERROR(MATCH($G2,FILTER($C:$C,$M:$M=1),0)),0))

FILTER 提取哪些 ID 在更新列 ColM 中具有“1”。

MATCH 查看 Dependency 列中的 ID 是否在该筛选列表中。

如果不匹配,IFERROR 将结果设置为零。

和初始 IF,过滤掉 Dependency 列中的 NA 值。

为每个依赖列复制此逻辑,因此三个 IF。

并且整个事情都包含在一个 OR 函数中,因此如果任何依赖项列具有匹配的 ID,则整行都被标记为红色。

我已将此应用到添加到您的 sheet、Test_1-GK 的选项卡中。

如果有帮助请告诉我。

恐怕我不明白你问题的第一部分。我对这一点感到困惑:

我想在 ID_3 的最后一个实例下方附加五行,在附加的行中,所有值都应与 ID_3 相同,除了 C 列将是现在是 ID_3_Append,K 列和 O 列对于附加行应该是空白的。

使用:

=ARRAYFORMULA(QUERY({QUERY({Test_1!A:O; 
 IFERROR(IF(IFNA(VLOOKUP(Test_1!C2:C, SORT({Test_1!C2:C, Test_1!K2:K}, 2, 0), 2, 0))=1, 
 {Test_1!A2:A, Test_1!B2:B, Test_1!C2:C&"_Append", Test_1!D2:J, Test_1!X2:X*0, 
  Test_1!L2:L, Test_1!X2:Y*0, Test_1!O2:O}, 
 {"","","","","","","","","","","","","","",""}), 
 {"","","","","","","","","","","","","","",""})}, 
 "where Col1 is not null and not Col3 matches '"&
 TEXTJOIN("|", 1, "×", UNIQUE(IF(IFNA(VLOOKUP(Test_1!C2:C, 
 SORT({Test_1!C2:C, Test_1!N2:N}, 2, 0), 2, 0))=1, Test_1!C2:C, )))&"' order by Col3", 1);
  
 IF(LEN(TEXTJOIN("|", 1, 
 UNIQUE(IF(IFNA(VLOOKUP(Test_1!C2:C, SORT({Test_1!C2:C, Test_1!N2:N}, 2, 0), 2, 0))=1, Test_1!C2:C, ))))>0, 
 QUERY({IF(Put_list!A2:A="",,IFERROR(Put_list!A2:A*1, "Put")), Put_list!A2:H, 
 IFNA(VLOOKUP(Put_list!B2:B&"♦"&COUNTIFS(Put_list!B2:B, Put_list!B2:B, ROW(Put_list!B2:B), "<="&ROW(Put_list!B2:B)), 
 {Test_1!C2:C&"♦"&COUNTIFS(Test_1!C2:C, Test_1!C2:C, ROW(Test_1!C2:C), "<="&ROW(Test_1!C2:C)), Test_1!J2:O}, {2,3,4,5,6,7}, 0))}, 
 "where Col3 matches '"&TEXTJOIN("|", 1, 
 UNIQUE(IF(IFNA(VLOOKUP(Test_1!C2:C, SORT({Test_1!C2:C, Test_1!N2:N}, 2, 0), 2, 0))=1, Test_1!C2:C, )), 
 UNIQUE(IF(IFNA(VLOOKUP(Test_1!C2:C, SORT({Test_1!C2:C, Test_1!N2:N}, 2, 0), 2, 0))=1, Test_1!C2:C&".+", )))&"'"), 
 {"","","","","","","","","","","","","","",""})}, "where Col1 is not null order by Col3", 1))


transcript:

we start with array of {C, K} columns that we sort based on K column so if K column contains 1 then it will be moved up                                                 
this is convinient for VLOOKUP coz it will always look for 1st unique value eg. exactly wat we need if our array is sorted                                                  
so we vlookup C values to match our sorted array and return column K for all same IDs                   2 stands for 2nd column from sorted array and 0 stands for "exact match"                                
if no match is found vlookup will output #N/A error so we wrap it into IFNA - then if no match is found vlookup will output empty rows                                                  
then we put this into IF statement... if our vlookup outputs 1, we output our columns (again in {array} form                                                    
if our vlookup outputs 0 then we output array of 15 empty cells in a row {"","","", .....}                  this is because we use arrays {} and all ranges in arrays needs to be of same size                              
                    our table has 15 columns so if some error would happen the we would get error in one single cell aganist our 15 columns                                 
                    this way we avoid "array_literal error" having {15 columns; 15 cells in a row which is also 15 columns}                             
                    ; semicolon puts these two arrays/ranges under each other while , comma will put then next to each other                                
so if vlookup results in 1 then we assemble our array with ranges... A, B columns are same then we append to C column the phrase "_Append" with &                                                   
D:J columns are same... then we force column of zeros by multipling random empty column (X) with 0                      etc.                            
then again we use {"","","", ....} within IFERROR to deal with any possible error at this point                                                 
next we put all written above under our whole range Test_1!A:O and we wrap it into QUERY where we state to filter out all empty rows where Col1 is empty and 2nd condition of our query states                                                  
that Col3 of our array cant match our regex pattern which we assemble with TEXTJOIN formula                                                 
    | stands for "or" in regex. 1 in textjoin means "all non empty cells". then we use × (unique symbol) in case textjoin would output empty cell on its own resulting in some error somewhere                                              
    again we perform same vlookup, same ifna and same IF but now we output only C column and we are interested only into UNIQUE values                                              
then within the query we sort / order by Col3 our table and 1 at the end stands for "header rows"