As a complete beginner to VBA Excel, I would like to be able to do the following:

I want to find the first value larger than 0 in a row, and then sum over the following 4 cells in the same row. So

```
Animal1    0    0    1    2    3    0    1
Animal2    3    3    0    1    4    2    0
Animal3    0    0    0    0    0    1    0

```

Results in

```
Animal1    7
Animal2    11
Animal3    1

```

Is this possible?
['https://Stackoverflow.com/questions/34811616', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4729787/']
This is the one of the variants of how you can achieve required result:

```
 Sub test()
        Dim cl As Range, cl2 As Range, k, Dic As Object, i%: i = 1
        Set Dic = CreateObject("Scripting.Dictionary")
        For Each cl In ActiveSheet.UsedRange.Columns(1).Cells
            For Each cl2 In Range(Cells(cl.Row, 2), Cells(cl.Row, 8))
                If cl2.Value2 > 0 Then
                    Dic.Add i, cl.Value2 & "|" & Application.Sum(Range(cl2, cl2.Offset(, 4)))
                    i = i + 1
                    Exit For
                End If
        Next cl2, cl
        Workbooks.Add: i = 1
        For Each k In Dic
            Cells(i, "A").Value2 = Split(Dic(k), "|")(0)
            Cells(i, "b").Value2 = CDec(Split(Dic(k), "|")(1))
            i = i + 1
        Next k
    End Sub

```

[![enter image description here](https://i.stack.imgur.com/rviN2.png)](https://i.stack.imgur.com/rviN2.png)
Here is what I would use, I dont know any of the cell placement you have used so you will need to change that yourself.

Future reference this isnt a code writing site for you, if you are new to VBA i suggest doing simple stuff first, make a message box appear, use code to move to different cells, try a few if statments and/or loops. When your comftable with that start using varibles(Booleans, string , intergers and such) and you will see how far you can go. As i like to say , "if you can do it in excel, code can do it better"

If the code doesnt work or doesnt suit your needs then change it so it does, it worked for me when i used it but im not you nor do i have your spread sheet

paste it into your vba and use F8 to go through it step by step see how it works and if you want to use it.

```
Sub test()

[A1].Select ' assuming it starts in column A1

'loops till it reachs the end of the cells or till it hits a blank cell
Do Until ActiveCell.Value = ""

ActiveCell.Offset(0, 1).Select

'adds up the value of the cells going right and removes the previous cell to clean up
Do Until ActiveCell.Value = ""
x = x + ActiveCell.Value
ActiveCell.Offset(0, 1).Select
ActiveCell.Offset(0, -1).ClearContents
Loop

'goes back to the begining and ends tallyed up value
Selection.End(xlToLeft).Select
ActiveCell.Offset(0, 1).Value = x

'moves down one to next row
ActiveCell.Offset(1, 0).Select

Loop

End Sub

```