# Application.WorksheetFunction.Sum problems

#### espenskeie

##### Well-known Member
Hi

I seem to have some problems with the sum function, the result is 0.

In those cells that I try to sum there are formulas, one =AVERAGE formula, and in the other cell a =STDEV formula.

This is my code:

Code:
``````Sub FillPeriodeAnalyze() ''''''''''''' Husk å endre denne dersom det legges en liste med tickere

Dim lr10 As Long
Dim m As Long
Dim longlimit As Long
Dim shortlimit As Long

lr10 = Sheets("1HourDATA").Range("V65536").End(xlUp).Row

With Sheets("1HourDATA")
longlimit = Application.WorksheetFunction.Sum(.Range("AR2:AS2"))
shortlimit = Application.WorksheetFunction.Sum(.Range("BB2:BC2"))

End With

For m = 2 To lr10

If Sheets("1HourDATA").Range("V" & m) >= longlimit Then
If Sheets("1HourDATA").Range("Z" & m) = "Low" Then
Sheets("1HourDATA").Range("AB" & m).Value = 1
End If
End If

If Sheets("1HourDATA").Range("W" & m) >= shortlimit Then
If Sheets("1HourDATA").Range("AA" & m) = "High" Then
Sheets("1HourDATA").Range("AB" & m).Value = 1
End If
End If

If Sheets("1HourDATA").Range("Z" & m).Value = "Low" Then
If Sheets("1HourDATA").Range("AA" & m).Value = "High" Then
Sheets("1HourDATA").Range("AB" & m).Value = ""
End If
End If
Next

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

End Sub``````

Regards
Espen

### Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
This worked for me:

Code:
``````Dim longlimit As Double
Dim shortlimit As Double``````

Replies
0
Views
167
Replies
1
Views
232
Replies
18
Views
396
Replies
2
Views
177
Replies
1
Views
202

1,203,524
Messages
6,055,905
Members
444,832
Latest member
bgunnett8

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back