View Full Version : [SOLVED] WorksheetFunction.Sum not working

07-01-2016, 05:02 AM
Hi All,

I am trying to run the below code. All variables are getting value except 'rsum"

Dim k As Integer, rsum As Double
Dim svalue As String
Dim numcol As Long
Dim strrng As Variant
Dim endrng As Variant
k = 7

Do While Sheets("BG").Cells(k, 11) <> ""
svalue = Sheets("BG").Cells(k, 11).Value
numcol = Application.WorksheetFunction.Match(svalue, Sheets(ws).range("$1:$1"), 0)
strrng = Sheets(ws).Cells(rstr, numcol).Address(False, False)
endrng = Sheets(ws).Cells(rend, numcol).Address(False, False)
rsum = Application.WorksheetFunction.Sum(range(strrng, endrng))
Sheets("bg").Cells(k, 12).Value = rsum
k = k + 1
Debug.Print svalue
Debug.Print strrng
Debug.Print endrng
Debug.Print k
Debug.Print rsum
End Sub

Can anyone give me ideas why? I am using debug.print to get values. Except for rsum everything else seems okay!!

rstr and rend are also working fine and m getting values for strrng and endrng

07-01-2016, 06:10 AM
Cross-posted Here (http://www.mrexcel.com/forum/excel-questions/950715-worksheetfunction-sum-not-working.html)

Himanshuk, please read Here (http://www.excelguru.ca/content.php?184-A-message-to-forum-cross-posters&page=1)

07-02-2016, 02:41 AM
Marked solved (http://www.mrexcel.com/forum/excel-questions/950715-worksheetfunction-sum-not-working.html#post4566493).