I am new to VBA / coding in general, and my usual tactic of gluing bits of pre-written code does not work for my problem.
I want to create a macro that will do 3 things:
- Let me find the starting point for the data in a column.
- Start counting the number of rows after the cell value is changed to a constant.
- As soon as the value returns to the starting point for stopping the count and writes down the number of cells counted in a separate column, with the position of the count in this column at the starting point of counting.
- Repeat until the end of the data.
In this case, the starting point will be when the cell has a value> 0. It will increase to a constant number (300). Sometime in 300, a macro will have to count the number of rows containing a numerical value of 300, until the value returns to 0. The number of reports in a separate table on a sheet with the record entered in the same relative position in the new table as with starting an account from the data. And finally, the cycle.
I also need to do a similar count, but in the horizontal direction (i.e. counting the columns in a row). If someone can create the code for the problem with the vertical / numerical line above, I would really appreciate it if you could annotate it so that I can try to understand / find out which bits of the code do each action and thereby change it for horizontal / column count
, , . - , / , . , , .
1 .
, , , .
Sub Count0()
For Each c In Worksheets("Sheet1").Range("D30:D39")
If c.Value = 0 Then
End If
If c.Value > 0 Then
v = Range(c.Value)
For i = 3 To Rows.Count
If Cells(i, 1).Value <> v Then
MsgBox CStr(i - 2)
End If
Next i
Next c
End Sub

