ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Charts and Charting in Excel (https://www.excelbanter.com/charts-charting-excel/)
-   -   Adding in loop (https://www.excelbanter.com/charts-charting-excel/97560-adding-loop.html)

Sally Mae

Adding in loop
 
I have a macro that now adds in a strange fashion. It used to work but now
for some reason the adding in one loop is wrong. When there are decimal
numbers in the cells that the loop is to add the program just puts them
together so that there are several decimal commas. The code is:

For l = 1 To i - 1
dblSumMarketValue = dblSumMarketValue + rng5.Offset(l, 0).Value
Next

For l = 1 To i - 1
dblSumMarketValueBench = dblSumMarketValueBench + rng6.Offset(l,
0).Value
Next

The last loop is the one having the problem. It used to work but now it just
puts the number together. The contents of the cells are pasted in from
another program and are then checked by a function that remove blanks (dont
know if that has any impact..). Please help me if you can!


Don Guillett

Adding in loop
 
why not just use
dsmv=Application.Sum(Range("a2:a4"))
or
Application.Sum(Range(Cells(2, "a"), Cells(4, "a")))
--
Don Guillett
SalesAid Software

"Sally Mae" wrote in message
...
I have a macro that now adds in a strange fashion. It used to work but now
for some reason the adding in one loop is wrong. When there are decimal
numbers in the cells that the loop is to add the program just puts them
together so that there are several decimal commas. The code is:

For l = 1 To i - 1
dblSumMarketValue = dblSumMarketValue + rng5.Offset(l, 0).Value
Next

For l = 1 To i - 1
dblSumMarketValueBench = dblSumMarketValueBench + rng6.Offset(l,
0).Value
Next

The last loop is the one having the problem. It used to work but now it
just
puts the number together. The contents of the cells are pasted in from
another program and are then checked by a function that remove blanks (don't
know if that has any impact..). Please help me if you can!





All times are GMT +1. The time now is 09:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com