excel formula and vba

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have this formula in cell:
=SUM(C12:L12)/((COUNTIF(C12:L12,">=0"))*24)

I need to be able to "convert" this to vba code.
??
thanks!!
 
one way :

Dim dblAnswer As Double
With WorksheetFunction
dblAnswer = .Sum(Range("C12:L12")) / (.CountIf(Range("C12:L12"), ">=0")
* 24)
End With
 
thank you Vergel. I think we are very close. This actually works but I
would like the formula in the cell instead of the value

-m
 
To put the formula in a cell, A1 for example:

Activesheet.Range("A1").Formula =
"=SUM(C12:L12)/((COUNTIF(C12:L12,"">=0""))*24)"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top