在Google电子表格中标记重复条目

mbb*_*mbb 6 google-app-engine google-sheets google-apps-script

我有一个电子表格,其中F列中的条目可能会在以后的F中重复.我正在寻找一些类似于此伪代码的东西:

While Ax is not empty

If value in Gx is empty   
  If cell Ex is identical to other cell Ey
  OR 
  If cell Fx is identical to other cell Fy 
     THEN
       Mark Gy as duplicate
       italics row y
Run Code Online (Sandbox Code Playgroud)

有关使用Google的内置应用脚本进行此工作的任何建议吗?

免责声明:我不熟悉JS,但我正在努力.

Jon*_*ren 9

你不需要JS.您可以使用内置电子表格公式来完成此操作.

听起来你想要一个我给这个问题的类似答案,不同的是你要检查两列而不是一列.

你要这个:

=if(AND(COUNTIF($A$1:$A2,A2)=1, COUNTIF($B$1:$B2,B2)=1), "", "Yes")
Run Code Online (Sandbox Code Playgroud)

需要注意的关键是使用ANDforumla.

这将在后续行中填充并显示如下:

=if(AND(COUNTIF($A$1:$A3,A3)=1, COUNTIF($B$1:$B3,B3)=1), "", "Yes")
=if(AND(COUNTIF($A$1:$A4,A4)=1, COUNTIF($B$1:$B4,B4)=1), "", "Yes")
...
Run Code Online (Sandbox Code Playgroud)

这些是使用电子表格数据作为示例的结果.这假设公式已插入Duplicate?列(C2)并填充:

   A                          B               C
1  Contact                    Name            Duplicate?
2  email@example.com          John  
3  repeat.email@example.com   Repeated Name 
4  repeat.email@example.com   Jane            Yes
5  email3@example.com         Repeated Name   Yes
Run Code Online (Sandbox Code Playgroud)

  • 谷歌的语法已经改变,这里是更新版本:`= IF(AND(COUNTIF($ A $ 1:$ A2; A2)= 1; COUNTIF($ B $ 1:$ B2; B2)= 1);"";"是" ")` (3认同)