I got a sub that works well except it takes times to run and at the end, my excel shuts down.
Sub testing_rows()
Dim ws As Worksheet
Dim nbTxt As Integer
Dim I As Integer
Set ws = Worksheets("Sheet4")
gp_lastrow = Range("A" & Rows.count).End(xlUp).Row
lastRow = Range("A:A").Cells.SpecialCells(xlCellTypeConstants).count
For I = 2 To 100
my_char = "-"
nbTxt = (Len(Range("A" & I)) - Len(Replace(Range("A" & I), my_char, ""))) / Len(my_char)
Range("BB" & I) = nbTxt
Next I
End Sub
Where gp_lastrow = 28.000 lines and lastrow = 18.000 How can I optimize this sub which is only a small part of what I want to do... on almost 30.000 lines.
Thx