countif in VB

M

mohavv

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
 
D

Dave Peterson

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