jmstarbuck
Programmer
I am trying to set the formula of a cell in my vb code. Here's what I am doing:
What ends up in the formula of the cell is:
=COUNTIF('D5':'D301', "<>0" )
What am I doing wrong? How can I get rid of the single quotes?
Any suggestions appreciated!
Code:
Dim myexpr As String
Dim myrange As String
myexpr = """<>0"""
myrange = "D5:D" & lastrow
ActiveCell.FormulaR1C1 = "=CountIf(" & myrange & ", " & myexpr & " )"
What ends up in the formula of the cell is:
=COUNTIF('D5':'D301', "<>0" )
What am I doing wrong? How can I get rid of the single quotes?
Any suggestions appreciated!