Hi, I am new to VBA.
I use this code: Worksheets("Data").Range("t19").Value = [COUNTIF(Data!W40:W174,">0.5")]
It is working nicely but I would like to use it in a loop and change the range W40:W174 in each iteration (i): W40:W(i). For example, for i = 173 the range would be W40:W173.
How should I rewrite the code to have a changeable range?
I tried the following but it is not working:
Dim i As Integer
i = 174
Worksheets("Data").Range("t19").Value = [COUNTIF(Range(.Cells(40, 23), .Cells(i, 23)),">0.5")]
Thank you in advance for any help.