简体   繁体   English

如果两个单元格包含相同的根URL,则删除行

[英]Delete row if both cells contain the same root URL

I have a two column spreadsheet. 我有两列电子表格。

In Column AI have one URL in Column BI have another URL. 在AI列中有一个URL,BI列中有另一个URL。

I want to delete the entire row if both cells in the same row contain the same root domain. 如果同一行中的两个单元格都包含相同的根域,我想删除整行。

Example: 例:

Delete the following 删除以下

Cell A1 = www.google.com 
Cell B1 = www.google.com/randomsubpage/anothersubpage

Keep the following 保持以下

Cell A1 = www.yahoo.com/randomsubpage/anothersubpage
Cell B1 = www.google.com/randomsubpage/anothersubpage

Is this possible? 这可能吗? If it's possible outside of Excel, I'm also open to suggestions. 如果有可能在Excel之外,我也欢迎您提出建议。

Thanks, 谢谢,

Sam 山姆

  1. Place this formula in cell C1 将此公式放在单元格C1中

    =IF(LEFT(A1,FIND(".com",A1)+3)=LEFT(B1,FIND(".com",B1)+3),"Delete","")

  2. Drag down the length of your data set. 向下拖动数据集的长度。

  3. Filter on Column C for Delete 筛选C列以进行删除

  4. Delete the filtered rows. 删除过滤的行。

This assumes all your urls are ".com". 假设您的所有网址均为“ .com”。 If you have ".net" or ".gov" or whatever, as well, you'll need to find a more common string to lookup in the FIND function and adjust the positioning accordingly. 如果您同时具有“ .net”或“ .gov”,则需要在FIND函数中查找更常见的字符串以进行查找并相应地调整位置。

This formula will work for multiple url endings: 此公式适用于多个网址结尾:

=IF(LEFT(A1,FIND(".",A1,FIND(".",A1)+1)+3)=LEFT(B1,FIND(".",B1,FIND(".",B1)+1)+3),"DELETE","")

I thought I should try and make it cope with http:// or https:// and possibly subdomains and domains like .tv but maybe I'm over-thinking it! 我以为我应该尝试使其与http://或https://以及可能的子域名和.tv之类的域名打交道,但也许我对此考虑过度! Not sure whether www should be considered part of the URL, but haven't put that in at present:- 不确定www是否应被视为URL的一部分,但目前尚未输入:-

=LEFT(SUBSTITUTE(SUBSTITUTE(A1,"http://",""),"https://","")&"/",FIND("/",SUBSTITUTE(SUBSTITUTE(A1,"http://",""),"https://","")&"/"))
=LEFT(SUBSTITUTE(SUBSTITUTE(B1,"http://",""),"https://","")&"/",FIND("/",SUBSTITUTE(SUBSTITUTE(B1,"http://",""),"https://","")&"/"))

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM