VBA计数包含指定值的列中的单元格 [英] VBA Count cells in column containing specified value

查看:250
本文介绍了VBA计数包含指定值的列中的单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要编写一个搜索指定列的宏,并对包含指定字符串的所有单元格进行计数,例如 19/12/11或Green 然后将此号码与一个变量相关联,

I need to write a macro that searches a specified column and counts all the cells that contain a specified string, such as "19/12/11" or "Green" then associate this number with a variable,

有没有人有任何想法?

推荐答案

你是说你想在VBA中使用一个公式吗?如下所示:

Do you mean you want to use a formula in VBA? Something like:

Dim iVal As Integer
iVal = Application.WorksheetFunction.COUNTIF(Range("A1:A10"),"Green")

应该工作。

这篇关于VBA计数包含指定值的列中的单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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