Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

I am trying to sum while running a loop. I want to add all the positive numbers from cell A1 to A10. I am a newbie, please post better code?

Sub result()

Dim randomNumbers As Range

For Each randomNumbers In Range("a1:a10")

With randomNumbers.Offset(0, 1)

Select Case randomNumbers.Value

Case Is >= 0

.Value = randomNumbers.Value

Case Is <= 0

.Value = 0

End Select

End With

Next randomNumbers

End Sub

1 Answer

Relevance
Still have questions? Get your answers by asking now.