ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   variable range in a COUNTIF statment (https://www.excelbanter.com/excel-programming/358478-variable-range-countif-statment.html)

Sabean

variable range in a COUNTIF statment
 
The position of the cells which have the data I want to check, change
depending on certain criteria. Is it possible in VBA to create a flexible
COUNTIF statement, where the range is a range object or something similar?
What is the sintax? Thanks

Tom Ogilvy

variable range in a COUNTIF statment
 
Dim rng as Range, cnt as Long
With Worksheets("sheet1")
set rng = .Range(.cells(5,1),.cells(5,1).End(xldown))
End With
cnt = Application.countif(rng,"AA")

--
Regards,
Tom Ogilvy


"Sabean" wrote:

The position of the cells which have the data I want to check, change
depending on certain criteria. Is it possible in VBA to create a flexible
COUNTIF statement, where the range is a range object or something similar?
What is the sintax? Thanks



All times are GMT +1. The time now is 05:24 PM.

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