VBA code to sum a row: syntax needed

  • Thread starter Thread starter slingsh0t
  • Start date Start date
S

slingsh0t

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!
 
One way:

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

Regards

Trevor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top