[英]Match The First And Last Character Of An Excel Spreadsheet Cell
I have a spreadsheet with addresses. 我有一个包含地址的电子表格。 Sometimes, those addresses are encapsulated in double-quotes. 有时,这些地址用双引号引起来。 I created a formula that I thought would work, but it isn't removing the double-quotes. 我创建了一个我认为会起作用的公式,但它并未删除双引号。 Obviously, it isn't matching the logic. 显然,这与逻辑不符。
Sample Data: 样本数据:
"194 Notch Ln."
My formula: 我的公式:
=IF(AND(RIGHT(A1)=""", LEFT(A1)="""), MID(A1, 1, LEN(A1)-1), A1)
Is there an issue with my formula? 我的公式有问题吗? Excel didn't throw up any errors. Excel没有引发任何错误。 I read that enclosing a double-quote in double-quotes would escape it (I'm using to "\\""
in PHP). 我读到用双引号引起来的双引号会使它转义(我在PHP中使用的是"\\""
)。
You should double your quotes within the quotes. 您应该在引号内将引号加倍。 So instead of """
, use """"
. 因此,而不是"""
,用""""
。
Also, Excel strings are one-based, so to grab the second character through the next-to-last character, do this: 此外,Excel字符串是基于一个字符串的,因此要通过倒数第二个字符来获取第二个字符,请执行以下操作:
=IF(AND(RIGHT(A1)="""", LEFT(A1)=""""), MID(A1, 2, LEN(A1)-2), A1)
You need to subtract 2 from the length of the string to account for the removed quotes. 您需要从字符串的长度中减去2来考虑删除的引号。
And as @jbarker2160 pointed out, SUBSTITUTE
may work better for this: 正如@ jbarker2160所指出的那样, SUBSTITUTE
可能对此更好地工作:
=SUBSTITUTE(A1,"""","")
Double双引号,使用:'= IF(AND(RIGHT(A1,1)=“”“”,LEFT(A1,1)=“”“”)= TRUE,MID(A1,2,LEN(A1)- 2),A1)'。
Or you could just use wild card characters as so: 或者,您可以按如下方式使用通配符:
=IF(COUNTIF(H10,"*"&"Notch"&"*"),1,0)
You could replace "Notch" with a cell reference. 您可以将“ Notch”替换为单元格引用。 "COUNTIF" will correctly evaluate the wildcards but "IF" by itself doesn't. “ COUNTIF”将正确评估通配符,但“ IF”本身不会。 This avoids having to remove the quotes, you could use the data as is depending on what you're trying to do downstream. 这样可以避免删除引号,您可以根据要在下游执行的操作按原样使用数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.