ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   REMOVE EMPTY LINES IN EXCEL CELL (https://www.excelbanter.com/excel-programming/435080-remove-empty-lines-excel-cell.html)

steve r

REMOVE EMPTY LINES IN EXCEL CELL
 
I need to remove the empty lines from individual cells (not remove entire rows)

-----
ROW1


-----

to

-----
ROW1
-----

Barb Reinhardt

REMOVE EMPTY LINES IN EXCEL CELL
 
Try this

Option Explicit

Sub test()
Dim aWS As Excel.Worksheet
Dim r As Excel.Range
Dim myText As String
Set aWS = ActiveSheet

For Each r In aWS.UsedRange
myText = Right(r.Text, 1)
If myText = Chr(10) Then
r.Value = Left(r.Text, Len(r.Text) - 1)
End If

Next r
End Sub


HTH,
Barb Reinhardt


"steve r" wrote:

I need to remove the empty lines from individual cells (not remove entire rows)

-----
ROW1


-----

to

-----
ROW1
-----



All times are GMT +1. The time now is 08:43 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com