为什么我的 Excel COUNTIF 函数总是返回值“0”?

为什么我的 Excel COUNTIF 函数总是返回值“0”?

我的 HTML 是:

div class="medium-insert-images" data-media-id="47deed170ef76561" data-original-width="590" data-original-height="350" contenteditable="false"figure    img src="https://cdn-blog.scorum.com/production/stanleyasokingz/47deed170ef76561_500" alt="" class="" data-original-width="590" data-original-height="350"        figcaption style="word-wrap: break-word; overflow: hidden;" class=""a href="https://www.google.com.ng/search?q=carlo+ancelotti&prmd=inv&source=lnms&tbm=isch&sa=X&ved=2ahUKEwjN86zU87DmAhXwxoUKHfngCOgQ_AUoAXoECA4QAQ&biw=360&bih=560&dpr=2#imgrc=avYy2TdjA1htFM"source/a/figcaption/figure/divpLooks like clubs firing their managers in an extreme fashion is whats in vogue lately. Within couple of months ago, we can definitely count about 7+ coaches who were relieved of their duties. Some come in as a shock while the others were expectant. Carlo Ancelotti becomes the latest victim to this sack riot as he parted ways with Napoli on Tuesday night after enormous champions league win over Genk and an advancement to the Round of 16. This is the second time I'm seeing a coach get sacked after winning a game. The other was Massimiliano Riccini who allowed his youth boys win 27-0./ppNo doubt the Italian is a high profiled coach with trophies and achievements at his name but this time, things really fell apart for him. Carlo went Nine games without a win in all competition until his Tuesday victory over Genk. Though he finished in second position last season after he took over from Mauzirio Sarri who left for Chelsea, the point gap between league winners (Juventus) and second placed Napoli was huge (11). This season they lie at the seventh position, far beyond the reach of the title. All hope lies in making top four for next season champions league game./pdiv class="medium-insert-images" data-media-id="84ca0d4c9366c665" data-original-width="678" data-original-height="452" contenteditable="false"figure    img src="https://cdn-blog.scorum.com/production/stanleyasokingz/84ca0d4c9366c665_500" alt="" class="" data-original-width="678" data-original-height="452"        figcaption style="word-wrap: break-word; overflow: hidden;" class=""a href="https://www.google.com.ng/search?q=carlo+ancelotti&prmd=inv&source=lnms&tbm=isch&sa=X&ved=2ahUKEwjN86zU87DmAhXwxoUKHfngCOgQ_AUoAXoECA4QAQ&biw=360&bih=560&dpr=2#imgrc=w6Ko_ZY8PYDB4M"source/a/figcaption/figure/divpLast month the manager and Napoli players were in a high-profile dispute with president Aurelio de Laurentiis. De Laurentiis ordered the team to attend a week-long training camp but Ancelotti and his players all returned home. This should be another reason for the untimely sack. The current relationship between Ancelotti, the president De Laurentiis and the club which is based on friendship, mutual esteem and respect looks like it remains unchanged despite sack. The funny part comes in here. Immediately after the victory over Genk, Ancelotti had told reporters he had no intention of resigning from his post. “I’ll see the President [on Wednesday] and we’ll see,† he said, not knowing the plans they've got for him. You never can tell, maybe he was even sacked while the game was going on. Just that there was no public hearing./ppbWas Ancelotti devalued?/b/ppThe Italian man is a fine and decorated coach though sometimes bad moments can make you look odd./pdiv class="medium-insert-images" data-media-id="1661b243aab20c0d" data-original-width="634" data-original-height="422" contenteditable="false"figure    img src="https://cdn-blog.scorum.com/production/stanleyasokingz/1661b243aab20c0d_500" alt="" class="" data-original-width="634" data-original-height="422"        figcaption style="word-wrap: break-word; overflow: hidden;" class=""a href="https://www.google.com.ng/search?q=ancelotti+wins+epl+with+chelsea&prmd=niv&source=lnms&tbm=isch&sa=X&ved=2ahUKEwj90-6Z9bDmAhXkxoUKHXulAbgQ_AUoAnoECA8QAg&biw=360&bih=560&dpr=2#imgrc=9n7tobUo445MeM"source/a/figcaption/figure/divpAncelotti, who won the Premier League and FA Cup Double with Chelsea in 2009-10, has been linked with the vacant managers' jobs at Arsenal and Everton and he is one out of the only three managers who boasts of winning three European Cups/Champions Leagues. The list contains Liverpool legend Bob Paisley and Zinedine Zidane. He won two Champions Leagues with AC Milan and one with Real Madrid, as well as domestic titles with Milan, Chelsea, Paris St-Germain and Bayern Munich. Carlo Ancelotti is the only manager in UCL history to guide a club from each of Europe’s top five leagues to the knock-out stages. ChelseağŸ ´ó  §ó  ¢ğŸ‡«ğŸ‡´, PSG🇫🇷 , Bayern Munich🇩🇪 , Real Madrid🇪🇸 , AC Milan, Napoli🇮🇹 . Now he’s done it with two Italian clubs💥💥👠🠽. Accolades well deserved./pdiv class="medium-insert-images" data-media-id="42739a09954383f7" data-original-width="720" data-original-height="418" contenteditable="false"figure    img src="https://cdn-blog.scorum.com/production/stanleyasokingz/42739a09954383f7_500" alt="" class="" data-original-width="720" data-original-height="418"        /figure/divp class=""Gennaro Gattuso has been appointed and given the opportunity as head coach following Ancelotti's sack. 41 years old Gattuso led AC Milan to the fifth position in Seria A last season but parted with the club this summer despite having ta years to run in his sea./ppHe equally spent 13 seasons with the club as a player and several of them under Ancelotti.br/ph2Thanks For Reading.../h2div class="medium-insert-images" data-media-id="3eae9990c5e1b49a" data-original-width="1024" data-original-height="1024" contenteditable="false"figure    img src="https://cdn-blog.scorum.com/production/stanleyasokingz/3eae9990c5e1b49a_800" alt="" class="" data-original-width="1024" data-original-height="1024"        /figure/div

我的公式是:

=COUNTIF(A1:A1,"*img*")

该值应该是 4,但它返回 0。

答案1

以下公式将测试单个单元格中的字符串。(我在其中使用的修改后的字符串相当于 OP 使用的字符串。它只是此处使用所需的版本。)

=SUM(IF(MID(J14,SEQUENCE(LEN(J14)),3)="img",1,0))

还有稍微短一点但更“圆滑”的:

=SUM(  (  MID(J14:J14,SEQUENCE(LEN(J14)),3)="img"  )  *1)

虽然我更喜欢第一种。另外,请注意,比较子句必须在其自己的括号中,否则会失败。值得注意的是,这是此类子句以最令人困惑的方式失败的常见原因,因为它似乎应该对您有用。这种失败的公式通常可以仅通过这一点来修复。

它们都测试所选文本中的每个三个字符串,以及由字符串的最后两个和一个字符组成的两个和一个字符串。(如果搜索两个或单个字符串而不是三个字符串,则最后一部分可能很重要并且需要考虑。)

请注意,原帖作者使用的公式无法得出正确的“8”,甚至无法得出她认为正确的“4”。它检查的是单元格,而不是字符串的元素,因此如果单元img格中存在,则*img*计算为“1”并继续。它不会像上面明确指出的那样查看每个组合,请注意还有更多示例。

但事实并非如此。想想这个字符串:

啊啊啊啊啊啊

img显然是匹配的,aaa开头的 是第一个星号通配符,然后“abcd”是第二个星号通配符。但是a*imgabc*也是匹配的,并且*imgab*……好吧……等等:通配符有很多组合,代表所有字符,不是img或部分字符。而且只有七个额外的字符可以用于这些组合。她的字符串长度为 5,925 个字符,所以……COUNTIF()有一个不可能完成的任务,即完成其设计的单元级工作,然后尝试完成单元内部的工作。

按照书写,结果应该为“1”。对我来说确实如此。所以我无法直接排除故障。

上述公式适用于单个单元格或单个单元格区域(如A1:A1),但如果给定多个单元格区域,则无效。我相信可以进行调整,可能以某种方式“嵌套”外部级别,但这不是要求的,而且现在是凌晨 3:30。

最后一点。Excel 可以将任何东西视为字符串,除了它自己的公式。由于它没有函数=HTML()(类似于=HYPERLINK()),因此没有 HTML 可以包含停止 Excel 字符串函数的方法。天哪,如果我们可以将 HTML 放入单元格中,然后 Excel 根据它运行代码,凯蒂会阻止我们。因此,在这样的字符串中没有隐藏或查看过去的材料。就此而言,如果可以的话,现在甚至可以通过 来破解公式FORMULATEXT()

相关内容