Excel或如果不起作用 [英] Excel Or in If Not Working

查看:94
本文介绍了Excel或如果不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Excel中,如果V列中的单元格不等于F或V,我只是试图删除一行.此代码将删除所有内容.这一定是愚蠢的,但我看不到.请帮忙!

In Excel, I am simply trying to delete a row if cells in column V is not equal to F or V. This code deletes everything. It has to be something stupid, but I can't see it. Please help!

For i = RowCount To 1 Step -1
     If Range("V" & i).Value <> "F" Or Range("V" & i).Value <> "V" Then Rows(i).Delete
Next i

推荐答案

您的逻辑似乎不正确.通过将or更改为and,您将可以评估适当的布尔运算.

Your logic seems incorrect. By changing the or to an and, you will then be evaluating the proper boolean arithmetic.

现在,您正在检查not "v"not "f",它们始终为假. 无论输入什么,答案总是正确的.

Right now, you are checking not "v" and not "f" which is always false. No matter the input, this will always have answer be true.

这篇关于Excel或如果不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆