How to write a procedure or formula to have in several cells a text that After a comma or others, return back starting a new ore in the same cell. This is possibile with ALT + Enter, but I need to do automatically in mano cells. Tks a lot
Hello @antonio1958 , you tagged this question with "Get and Transform". Does that mean you want to do that with Power Query?
You could do a find and replace to replace a comma with the Ascii character 10.
If you want to do this with VBA, you can use code along these lines:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A:C")) Is Nothing Then
Application.EnableEvents = False
Target.Replace What:=", ", Replacement:="" & Chr(10) & "", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
Target.WrapText = True
Application.EnableEvents = True
This code looks at columns A to C. When a cell in these columns is edited, any comma followed by a space will be replaced with a new line and the cell will be formatted to wrap text.
To use this code, right-click on the sheet tab and select "View Code". That will open the Code Editor Paste the code into the big code window area.