ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Formula (https://www.excelbanter.com/excel-programming/303212-formula.html)

tj

Formula
 
Does anyone know the vba code to show a summation in an
excel formula as =SUM(A1,A2,A3,A4) --- the only ones I
know show up as =SUM(A1:A4)






MSP77079[_26_]

Formula
 
the VBA code is exactly as you wrote it.

But, as long as you are in VBA, why would you want to do it that way?

Why not:

Total = 0
For i = 1 to 4
Total = Total + cells(i, "A")
Next

--
Message posted from http://www.ExcelForum.com


Harlan Grove

Formula
 
"MSP77079 " wrote...
the VBA code is exactly as you wrote it.

But, as long as you are in VBA, why would you want to do it that way?

Why not:

Total = 0
For i = 1 to 4
Total = Total + cells(i, "A")
Next i


Perhaps either

Total = Evaluate("SUM(A1:A4)")

or

Total = Application.WorksheetFunction.Sum(Range("A1:A4"))

run more quickly than your For loop.




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

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