ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   VBA code to sum a row: syntax needed (https://www.excelbanter.com/excel-discussion-misc-queries/34738-vba-code-sum-row-syntax-needed.html)

[email protected]

VBA code to sum a row: syntax needed
 
I've got some code going, and need to perform a function if the sum of
cells between columns DZ and EP on every row exceeds zero. What is the
code to sum a range?

Range("dz" & selection.row).value + Range("ea" & selection.row).value +
etc is too cumbersome. What's the better way?

Thanks!


Trevor Shuttleworth

One way:

Sub test()
With Selection
Range("dx" & .Row) = WorksheetFunction.Sum _
(Range("dz" & .Row & ":ep" & .Row))
End With
End Sub

Regards

Trevor


wrote in message
ups.com...
I've got some code going, and need to perform a function if the sum of
cells between columns DZ and EP on every row exceeds zero. What is the
code to sum a range?

Range("dz" & selection.row).value + Range("ea" & selection.row).value +
etc is too cumbersome. What's the better way?

Thanks!





All times are GMT +1. The time now is 08:35 PM.

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