espenskeie
Well-known Member
- Joined
- Mar 30, 2009
- Messages
- 636
- Office Version
- 2016
- Platform
- Windows
Hello
I have a column with some positive and some negative values, and also some empty cells.
I try to figure out how to write a VBA code for this, and would prefer to avoid .formula codes if possible...
This is what I have been messing with so far, completely without success:
Regards
Espen
I have a column with some positive and some negative values, and also some empty cells.
I try to figure out how to write a VBA code for this, and would prefer to avoid .formula codes if possible...
This is what I have been messing with so far, completely without success:
Code:
Sub TEst(rRange As Range)
rRange As Double
Application.Volatile True
Dim rSumRange As Range
Dim tosum As Long
Set rSumRange = .Range("AD2", .Cells(Rows.count, 31).End(xlUp))
For Each rSumRange In rRange
With rSumRange
If IsNumeric(.Value) Then
If .Value > 0 Then
tosum = tosum + .Value
End If
End If
End With
Next rSumRange
.Range("AD" & lrAna).Value = tosum
End Sub
Regards
Espen