View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
rog rog is offline
external usenet poster
 
Posts: 39
Default countif syntax VBA

Just a few quotes in the wrong place Dave :

"=COUNTIF(R[4]C:R[" & counter & "]C,""" & "d1"")"

-----Original Message-----
xl 2k
Win 2k

Trying to use VBA to enter a formula, must use RC
notiation so I can use variable number of rows, and then
will copy the formula using relative ranges and but still
mustuse a specific cell for the criteria.

sample snippet

Sub fixcount()
Dim counter As Integer
counter = 5
'what I want....
'Sheets("Test").Range("d3").FormulaR1C1 = "=COUNTIF(R[4]

C:R
[" & counter & "]C,""" & value in a fixed cell & ")"""

'what I have --doesn't work run time 1004
Sheets("Test").Range("d3").FormulaR1C1 = "=COUNTIF(R[4]C:R
[" & counter & "]C,""" & "d1" & ")"""
End Sub

Is my problem a mix of RC and the "D1" notations?
TIA Dave
.