Don Stevens
Don Stevens

Reputation: 1

vba countif expression

I need to count number of integers in top 1/3, middle 1/3 and bottom 1/3 of an array (test array in C6:C28). But I can't seem to get countif to work.

Range("C1").Select
    ActiveCell.FormulaR1C1 = "=MAX(R[2]C:R[24]C)"
Range("D1").Select
    ActiveCell.FormulaR1C1 = "=RC[-1]/3"
Range("E1").Select
    ActiveCell.FormulaR1C1 = "=2*RC[-1]"
Range("C2").Select
  ActiveCell.FormulaR1C1 = "=COUNTIF(R[4]C:R[26]C,""<D1"")"
Range("C3").Select
  ActiveCell.FormulaR1C1 = "=COUNTIF(R[3]C:R[25]C,"">E1"")"

185 
115 
208 
101 
2   
53  
348 
169 
10  
24  
243 
93  
357 
326 
17  
84  
253 
198 
250 
352 
51  
98  
216 

Upvotes: 0

Views: 1710

Answers (1)

assylias
assylias

Reputation: 328568

One possible source of error is this "=COUNTIF(R[4]C:R[26]C,""<D1"")" - you should extract the cell address from the string:

"=COUNTIF(R[4]C:R[26]C,""<""&D1)"

Same comment for the next formula.

Upvotes: 2

Related Questions