View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
ELLIEOL ELLIEOL is offline
external usenet poster
 
Posts: 1
Default SUM Function Yields Zero Result

I tried to use the SUM function in VBA. I had used similar code successfully before, but now get a zero result, even if there are non-zero numbers in the range. Here's the code. Of course, nRow, nCol and NumColsOutput have been previously defined.

Set zRange = .Range(.Cells(nRow, nCol), .Cells(nRow, NumColsOutput))
Sum = WorksheetFunction.Sum(zRange)

If I use "zRange.Select", I can see that it is selecting the desired range of cells, so the Range works correctly, yet the SUM is wrong.

I then tried the simple worksheet function, entered into a cell: =SUM(A1:D3)

I found that sometimes I got a zero result, sometimes a non-zero result.

Can anyone suggest why I might be getting these "false" zero results from the SUM function?

Thank you very much for any help you may be able to offer.