Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
SUM Function Yields Zero Result
If there's always data in the range when you're using =sum
then it must be formatted as text. Are you importing data from somewhere else? You get this kind of problem sometimes if you're pulling data from Crystal Reports, but I don't know about anything else. Pete. -----Original Message----- 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. . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Month function yields incorrect solution | Excel Worksheet Functions | |||
Production Yields | New Users to Excel | |||
Substitute function yields #VALUE! when add the instance_number | Excel Worksheet Functions | |||
Need help with bond yields | Excel Discussion (Misc queries) | |||
ACCRINT formula yields incorrect result | Excel Worksheet Functions |