Excel countif vba code with criteria resulting with values

大城市里の小女人 提交于 2019-12-02 07:35:52

Declare all your variables, e.g.,

Dim MyRange as Range, MyCell as Range.

Without declaration, MyCell is variant data type, and that is why you're getting an Object Required error. Then do:

For Each MyCell In MyRange.Cells

Inside the With block, you may want to use (note the . in front of Cells):

If .Cells.Find(MyCell.Value) Is Nothing Then

Further, you will probably need to revise what you're doing with ActiveCell, since this is never changing which cell is active, I'm not sure it would give you the expected results. It is always preferable to avoid relying on Active and Select methods (except for to use them as user-input). INstead, work with the range objects directly.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!