谷歌书签删除重复_如何删除Google表格中的重复项

谷歌书签删除重复

谷歌书签删除重复

Google Sheets lets you remove duplicates from your document with three methods ranging from a simple integrated function to a custom script. While it’s not as apparent as in Excel, Sheets offers a more diverse way to remove duplicates in your spreadsheet.

Google表格可以让您通过三种方法(从简单的集成函数到自定义脚本)从文档中删除重复项。 虽然它不像在Excel中那样明显 ,但是Sheets提供了一种更加多样化的方法来删除电子表格中的重复项。

Update: You can now do this with the built-in “Remove Duplicates” tool in Google Sheets.

更新 :现在,您可以使用Google表格中的内置“ 删除重复项 ”工具来执行此操作。

使用唯一功能删除重复项 (Remove Duplicates Using the Unique Function)

The first method we’re going to look at uses the built-in Google Sheets function that finds all unique entries, letting you get rid of everything else in the data set.

我们将要研究的第一种方法是使用内置的Google表格功能来查找所有唯一条目,从而摆脱数据集中的所有其他内容。

Fire up your browser and open up a spreadsheet to get started.

启动浏览器并打开电子表格以开始使用。

A sample table with duplicates

Next, click the empty cell where you want the data to output, type =UNIQUE, and then click on the suggested function that appears in the dialog window.

接下来,单击要在其中输出数据的空单元格,键入=UNIQUE ,然后单击出现在对话框窗口中的建议功能。

Select an empty cell and start typing =Unique, then click on the suggestion that appears

From here, you can either manually enter the range of cells or highlight them for the function to parse. When you’re done, hit Enter.

在这里,您可以手动输入单元格的范围,也可以突出显示它们以供函数解析。 完成后,按Enter。

Highlight the rows/cells you want the function to search through, then hit Enter

Just like magic, Sheets picks out all the unique results and displays them in the selected cell.

就像魔术一样,Sheets会挑选出所有唯一结果并将其显示在所选单元格中。

The unique entries that were found will appear outside your table below the function's cell

If you copy and paste the information back into a Google Sheet, be sure to right-click where you want to paste and then choose Paste Special > Paste Values Only—otherwise, only the formula gets copied into the new cell.

如果您将信息复制并粘贴回Google表格中,请确保右键单击要粘贴的位置,然后选择“选择性粘贴”>“仅粘贴值”-否则,仅将公式复制到新单元格中。

If you copy and paste the information back into a Google Sheet, be sure to right-click, then choose Paste Special > Paste Values Only

使用附加组件删除重复项 (Remove Duplicates Using an Add-On)

For the next method, you’ll need to install an add-on to Google Sheets. If you’ve never used an add-on before, they’re similar to browser extensions that unlock extra additional features for you inside of Google apps, like Docs, Sheets, and Slides.

对于下一种方法,您需要在Google表格中安装插件 。 如果您以前从未使用过插件,则它们类似于浏览器扩展程序,可以在Google应用程序内为您解锁额外的附加功能,例如文档,表格和幻灯片。

For this example, we’ll be using Remove Duplicates by AbleBits. It comes with a free trial for 30 days; premium memberships are $59.60 for a lifetime subscription or $33.60 annually.

在此示例中,我们将使用AbleBits删除重复项 。 它具有30天的免费试用期; 高级会员的终身订阅费用为59.60美元,或每年33.60美元。

安装附加组件 (Installing the Add-On)

To get an add-on, open a file in Google Sheets, click “Add-ons,” and then click “Get add-ons.”

要获取加载项,请在Google表格中打开一个文件,单击“加载项”,然后单击“获取加载项”。

Open Add-Ons menu, then click Get Add-Ons

Type “Duplicates” into the search bar and then click the “Free” button.

在搜索栏中输入“重复项”,然后单击“免费”按钮。

Type Duplicates into the search bar, then click Free on the add-on you want to install

Click on the Google account you want to use to install the add-on.

单击您要用于安装附件的Google帐户。

Choose an account to install the add-on

Upon installing add-ons, you need to grant them specific permissions. These are fundamental to the operation of the add-on. Make sure you fully understand the permissions and trust the developer before installing any add-on.

安装加载项后,需要授予他们特定的权限。 这些是插件操作的基础。 在安装任何附加组件之前,请确保您完全理解权限并信任开发人员。

Click “Allow.”

点击“允许”。

Read and review the permissions for the add-on, then click Allow

使用附加组件 (Using the Add-on)

You can use the Remove Duplicates add-on for a single column or across multiple rows. In this example, we’ll be looking for duplicates in rows, but it works mostly the same for a single column.

您可以对单列或多行使用“删除重复项”加载项。 在此示例中,我们将在行中查找重复项,但对于单个列,其工作原理几乎相同。

In your spreadsheet, highlight all the rows you want to search for duplicates. After that, click Add-ons > Remove Duplicates > Find duplicate or unique rows.

在电子表格中,突出显示要搜索重复项的所有行。 之后,单击附加组件>删除重复项>查找重复或唯一行。

Highlight the rows you want to search, click Add-ons, point to Remove Duplicates, then click on Find duplicate or unique rows

After the add-on opens, check to make sure the range listed is correct and then click “Next.”

加载项打开后,检查以确保列出的范围正确,然后单击“下一步”。

Check to make sure the range listed is correct, then click Next

Next, choose the type of data you want to find. Because we’re removing duplicates, select “Duplicates” and then click “Next.”

接下来,选择要查找的数据类型。 因为我们要删除重复项,所以选择“重复项”,然后单击“下一步”。

Select Duplicates, then click Next

Select the columns for the add-on to search. If you didn’t include the headers—or maybe your table doesn’t have any headers at all—making sure to untick the “My table has headers” option. Otherwise, the first row will be omitted. Click “Next.”

选择要搜索的加载项的列。 如果您不包括标题(或者您的表根本没有任何标题),请确保取消选中“我的表有标题”选项。 否则,将省略第一行。 点击下一步。”

If your tables doesn't have headers, deselct My Table Has Headers, then click Next

Finally, choose what the add-on will do with its findings and then click “Finish.”

最后,选择加载项将如何处理其发现,然后单击“完成”。

Choose what you want to happen with the results, then click Next

On the results page, the add-on tells us that four duplicate rows were found and removed.

在结果页面上,该加载项告诉我们找到并删除了四个重复的行。

The results page showing how many entries were found in your document

Voila! All duplicate rows disappear off of your sheet.

瞧! 所有重复的行将从工作表中消失。

The updated table without any of the duplicated entries

使用Google脚本编辑器删除重复的行 (Remove Duplicate Rows with Google Script Editor)

The final method for removing duplicates in your sheet involves using Google App Script, a free-to-use cloud-based development platform for creating custom, light-weight web applications. Although it involves writing code, don’t let that scare you off. Google provides extensive documentation and even supplies you with the script for removing duplicates. Just copy the code, verify the add-on, and then run it inside your sheet.

删除工作表中重复项的最后一种方法涉及使用Google App Script ,这是一个免费的基于云的开发平台,用于创建自定义的轻量级Web应用程序。 尽管它涉及编写代码,但是不要让它吓到您。 Google提供了广泛的文档 ,甚至为您提供了用于删除重复项的脚本。 只需复制代码,验证加载项,然后在工作表中运行它即可。

From the current Google Sheet, click “Tools” and then click “Script Editor.”

在当前的Google表格中,单击“工具”,然后单击“脚本编辑器”。

Click Tools, then click on Script Editor

Google Apps Script opens in a new tab with an empty script.

Google Apps脚本会在一个带有空脚本的新标签页中打开。

An empty function for your bound script

Delete the empty function inside the file and paste in the following code:

删除文件中的空函数,然后粘贴以下代码:

//Removes duplicate rows from the current sheet.

 function removeDuplicates() {
//Get current active Spreadsheet
 var sheet = SpreadsheetApp.getActiveSheet();
//Get all values from the spreadsheet's rows
 var data = sheet.getDataRange().getValues();
//Create an array for non-duplicates
 var newData = [];
//Iterate through a row's cells
 for (var i in data) {
   var row = data[i];
   var duplicate = false;
   for (var j in newData) {
    if (row.join() == newData[j].join()) {
     duplicate = true;
    }
  }
//If not a duplicate, put in newData array
 if (!duplicate) {
  newData.push(row);
 }
}
//Delete the old Sheet and insert the newData array
 sheet.clearContents();
 sheet.getRange(1, 1, newData.length, newData[0].length).setValues(newData);
}

Save and rename your script. Hit the “Run” icon when you’re done.

保存并重命名脚本。 完成后,点击“运行”图标。

Click the Run icon

You’ll have to review the permissions your script requires and grant it access your spreadsheet. Click “Review Permissions” to see what access this script wants.

您必须查看脚本所需的权限,并授予其访问电子表格的权限。 单击“查看权限”以查看此脚本需要的访问权限。

Click Review Permissions to view the requested permissions

Accept the prompts and then click “Allow” to authorize the script.

接受提示,然后单击“允许”以授权脚本。

Review the permissions, then click Allow

After it finishes running, go back to your Sheet and, just like the previous methods, all duplicate entries vanish from your file!

完成运行后,返回到工作表,就像以前的方法一样,所有重复的条目都将从文件中消失!

The duplicate data points have been removed!

Unfortunately, if your data is inside of a table—like the example shown above—this script will not resize the table to fit the number of entries in it, and you’ll have to fix that manually.

不幸的是,如果您的数据在表中(如上面的示例所示),则此脚本将不会调整表的大小以适合表中条目的数量,因此您必须手动对其进行修复。



That’s all there is to it. Whether you want to use the integrated Unique function, a third-party add-on, or create a custom add-on with Apps Script, Google gives you multiple ways to manage duplicates in your spreadsheet.

这里的所有都是它的。 无论您是要使用集成的唯一功能,第三方加载项,还是要通过Apps脚本创建自定义加载项,Google都可以为您提供多种方法来管理电子表格中的重复项。

翻译自: https://www.howtogeek.com/413134/how-to-remove-duplicates-in-google-sheets/

谷歌书签删除重复

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值