ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   countif in VB (https://www.excelbanter.com/excel-discussion-misc-queries/181943-countif-vbulletin.html)

mohavv

countif in VB
 
Hi,

Can this be done shorter, without using cell B1

Range("B1").Formula = "=COUNTIF(A:A,""*Stock*"")"
Stock = Range("B1").Value
Range("B1").Clear

Cheers,

Harold

Dave Peterson

countif in VB
 
Dim Stock As Long
Stock = Application.CountIf(ActiveSheet.Range("a:a"), "*stock*")
MsgBox Stock


mohavv wrote:

Hi,

Can this be done shorter, without using cell B1

Range("B1").Formula = "=COUNTIF(A:A,""*Stock*"")"
Stock = Range("B1").Value
Range("B1").Clear

Cheers,

Harold


--

Dave Peterson


All times are GMT +1. The time now is 02:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com