H
Howard
Starting with R26 over to AK26, count the number of consecutive zeros starting with row 26 and down until no more data OR a cell <> 0.
Then that total goes into cell 20 of the row being counted.
If first cell is not a zero then cell 20 = 0, go to next column.
Thanks.
Regards,
Howard
Option Explicit
Sub nestingLoops()
Dim iCell As Range
Dim cCell As Long
For Each iCell In ActiveSheet.Range("R26:AK26")
With iCell
If iCell <> 0 Then
cCell = 0
'then cell 20 of this column = cCell.Value (which is 0)
'move to S26 and do the same until AK26
ElseIf iCell = 0 Then
cCell = cCell + 1
'go to next cell down and if it = 0
'cCell = cCell + 1 (which is now 2)
'go to next cell down and next cell down until cell <> 0 _
'OR the end of the data in this column
'then cell 20 of this column = cCell.Value _
'(which is the total of consective cells that did = 0)
'then go to S26 and do the same until AK26
End If
End With
Next iCell
End Sub
Then that total goes into cell 20 of the row being counted.
If first cell is not a zero then cell 20 = 0, go to next column.
Thanks.
Regards,
Howard
Option Explicit
Sub nestingLoops()
Dim iCell As Range
Dim cCell As Long
For Each iCell In ActiveSheet.Range("R26:AK26")
With iCell
If iCell <> 0 Then
cCell = 0
'then cell 20 of this column = cCell.Value (which is 0)
'move to S26 and do the same until AK26
ElseIf iCell = 0 Then
cCell = cCell + 1
'go to next cell down and if it = 0
'cCell = cCell + 1 (which is now 2)
'go to next cell down and next cell down until cell <> 0 _
'OR the end of the data in this column
'then cell 20 of this column = cCell.Value _
'(which is the total of consective cells that did = 0)
'then go to S26 and do the same until AK26
End If
End With
Next iCell
End Sub