Hi..
This will take care of the zero's..
Private Sub CommandButton1_Click()
Dim x, Z As Long
For Each Cell In Range("C2:C" & Range("C" & Rows.Count).End(xlUp).Row)
x = Cell.Offset(, 1).Resize(, 51).Value
Cells(1, 85).Resize(50).Value = Application.Transpose(x)
With Columns(85)
x = .Replace("0", "")
End With
On Error Resume Next
Z = Application.Max(Columns(85).SpecialCells(2).Areas.Count)
Cell.Offset(, 52).Value = Z: Z = 0
On Error GoTo 0
Columns(85).ClearContents
Next Cell
End Sub
I tried watersev's code as it looked like a nice idea..
I modified it slightly to iterate through all your rows and also needed to set the range to be the last used column cell or it would add 1 to the count (as there may well be a area between last used value and bb)..
Private Sub CommandButton2_Click()
Dim zero_rng As Range, result, LastCol As Long
For i = 2 To Range("C" & Rows.Count).End(xlUp).Row
LastCol = Range("IV" & i).End(xlToLeft).Column
On Error Resume Next
Set zero_rng = Range(Cells(i, 2), Cells(i, LastCol)).Find(0, , xlValues, xlWhole)
If zero_rng Is Nothing Then result = 0 Else result = Range(Cells(i, 4), Cells(i, LastCol)).RowDifferences(zero_rng).Areas.Count
Cells(i, 55).Value = result: result = 0
On Error GoTo 0
Next i
End Sub
Thanks to watersev for this method.. I have never used it before..
Attached is a workbook showing both options.. you will need to clear column BC before running watersevs (if you have already run mine previously)..
Bookmarks