sum formula and if

M

Mathieu

Hi,

I am trying to make the vba make a small calculation without success. I have
tried the formula below.

What I want to do is : if (sum of AH2 to AH1000) is greater than ( 0 ) do
this, else do that.

Thanks!

Dim ca As Variant

'ca = "=sum(AH2:AH1000)"
'ca = "=SUM(R[2]C[33]:R[1000]C[33])"
'ca=FormulaR1C1 = "=sum(AH2:AH1000)"

If ca > 0 Then
do this

Else

do that

End If
 
D

Don Guillett

Sub addif()
If Application.Sum(Range("AH2:AH1000")) > 0 Then
MsgBox "HI"
else
msgbox "no"
end if
End Sub
 
M

Mathieu

Thank you very much! I'll remember the "application.*"
--
Mathieu


Don Guillett said:
Sub addif()
If Application.Sum(Range("AH2:AH1000")) > 0 Then
MsgBox "HI"
else
msgbox "no"
end if
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(e-mail address removed)
Mathieu said:
Hi,

I am trying to make the vba make a small calculation without success. I
have
tried the formula below.

What I want to do is : if (sum of AH2 to AH1000) is greater than ( 0 ) do
this, else do that.

Thanks!

Dim ca As Variant

'ca = "=sum(AH2:AH1000)"
'ca = "=SUM(R[2]C[33]:R[1000]C[33])"
'ca=FormulaR1C1 = "=sum(AH2:AH1000)"

If ca > 0 Then
do this

Else

do that

End If
 

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

Top