Abdullah Nasir
Abdullah Nasir

Reputation: 74

Remove first lines within cells in libreoffice calc

I have a large no of cells in libreoffice calc, and every cell have two lines. I want to remove every first line from each cell. Any easy method? This piece of code works perfect in VBA excel but dont run in libreoffice calc.

{ Sub RemoveFirstLine(ByRef Target As Range)

Dim xCell As Range

For Each xCell In Target.Cells

    xCell.Value = Right(xCell.Value, Len(xCell.Value) - InStr(1, xCell.Value, vbLf))

Next

End Sub

Sub StartRemove()

Dim xRng As Range

On Error Resume Next

Set xRng = Application.InputBox("Please select range:", "Excel 10 Tutorial", Selection.Address, , , , , 8)

If xRng Is Nothing Then Exit Sub

On Error Resume Next

RemoveFirstLine xRng

End Sub }

enter image description here

Upvotes: 0

Views: 282

Answers (1)

JohnSUN
JohnSUN

Reputation: 2539

You don't need a macro for this task, use Find&Replace.

Press Ctrl+H or choose Edit-Find&Replace

Input to field Find .*\n, set Other Options - Regular expressions to ON, click Replace All

Remove first lines.png

Upvotes: 0

Related Questions