I am trying to count the number of commas in each line of my Excel file.
So I first decided to count the total number of rows
and then count the number of commas in each row.
I wrote this code. But I keep getting an error saying Next without for.
I can't understand whats wrong. Please Rectify this.
Sub Give_The_Last_Row()
Selection.SpecialCells(xlCellTypeLastCell).Select
LastRow = ActiveCell.Row
MsgBox (LastRow)
End Sub
Sub Counting_Commas()
For j = 1 To 59
Count = 0
No_Comma = 0
For i = 1 To Len(Cells(j, 1))
If Mid(Cells(j, i), i) = "," Then
Count = Count + 1
Else: No_Comma = No_Comma + 1
Next i
Count = activeCount
MsgBox (Count)
Cells(41, j) = Count
Next j
MsgBox (Count)
End Sub
Bookmarks