How should I delete a row if it is over a certain amount of characters with a macro?

I need to sort through a bunch of rows with email addresses, names, and other information to remove the spam emails. Since real names are usually under fifteen characters, I decided to delete all the rows that have over fifteen characters. I tried to write a macro to do this, but all it is doing is deleting some rows, over fifteen characters or not.

Sub Main
Dim currDoc as Object
Dim currSheet as Object
Dim currCell as Object

Dim cellString as String
Dim stringLength as Integer


currDoc = ThisComponent
currSheet = currDoc.sheets(0)

For i = 1 To 100000 Step 1
	currCell = CurrSheet.getCellByPosition(1, i)
	cellString = currCell.String
	stringLength = LENB(cellString)
	
	If stringLength > 15 Then
		currSheet.rows.RemoveByIndex(1, i)

		
	End If
	
	
Next

print "Finished"	
End Sub

LENB >> Len

If less than 100,000 rows of data? Use the index of the last row of UsedArea or CurrentRegion. If the rows are deleted, you need to move backward:

For lastRow To 1 Step -1

In your case deletion breaks indexing.

Why “with a macro”?
This is very simple using a Standard Filter:

Select the critical column.
>Data>More Filters>Standard Filter...
+Options, Enable Regular expressions.
Into top Field line, below “Value”, enter .{16,} exactly as given here.
OK
(Only rows with >= 16 characters in the respective cell are still shown now.)
RightClick on one of the highlighted row headers.
Select Delete Rows.
Ctrl+A (Select All)
RightClick on one of the highlighted row headers.
Select Show Rows

Done

@Lupp, “with a macro” was the question. If TS can write such a macro he probably knows about standard filter.

I know what the question was, and I felt free to suggest an alternative solutuon. Of course, I also can implement the solution described based on UI means by a maxcro, and actually I did… I can not offer sufficient help concerning the API to enable the questioner to write the macro himself. Judging from what he posted I wouldn’t expext him to be sufficiently familiar with the API.
If he is, your hint should help him to accomplish the task. On the other hand the questioner may well know the Stanndard Filter, but not have the hunch he could use it in the context.
See alo: Doneask319946specialDeleteRowsDraft.ods

@Lupp, the standard filter via UI will not filter the non-contiguous range, but the code in your example will do it within the UsedArea.

Although it is bad practice to break the range.