Re: Auto Replace A Text String With A "newline" (like an Alt-Enter within a cell)
Quote from Aaron Blood
Do you want it to happen on a specific sheet or for any worksheet in a workbook?
If it were me doing the typing, I'd shorten the string to: %LF
...or are you copy/pasting it in there?
It would be nicer if it worked on any sheet in the workbook, but if it's easier to do on a specific sheet only, that's OK too.
The data already exists in a .CSV file (and already has the %newline% in the cells). Because the data isn't always in the same cells, it's a lot easier to do a quick copy/paste from some cells in the .CSV file into this workbook with the macro.
Having the new lines convert automatically without manually running the macro each time makes things a lot easier since I copy/paste different cells from that file often.
Thanks in advance again!
CG[hr]*[/hr] Auto Merged Post;[dl]*[/dl]I think I've got it. I've attached the code below for anyone that might stumble into this thread in the future. Also thanks again to Aaron and Turtle who I could have not done this without!
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Cells.Replace " %newline% ", vbLf
Cells.Replace "%newline% ", vbLf
Cells.Replace " %newline%", vbLf
Cells.Replace "%newline%", vbLf
Application.EnableEvents = True
End Sub