Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to split and wrap text
In column (D) I have a variable range of data where some cells have data
which includes a "|" character. I need a macro which runs down col D - until the last populated row in Col E - and if there is a cell with a "|" it deletes the character and wraps the text as if I pressed Alt+Enter on the keyboard. I would really appreciate some help with the code especially how I replicate the Alt+Enter part of the process as I am totally stuck. Many thanks in anticipation |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to split and wrap text
this should get you started.
Sub ReplaceCharacters() Dim rng As Range Set rng = Cells(1, "D").Resize( _ Cells(Rows.Count, "E").End(xlUp).Row, 1) rng.Replace What:="|", _ Replacement:=vbLf, _ LookAt:=xlPart, _ SearchOrder:=xlByRows, _ MatchCase:=False rng.WrapText = True rng.EntireColumn.AutoFit End Sub Obviously test it on a copy of your sheet since it changes data. -- Regards, Tom Ogilvy "nospaminlich" wrote: In column (D) I have a variable range of data where some cells have data which includes a "|" character. I need a macro which runs down col D - until the last populated row in Col E - and if there is a cell with a "|" it deletes the character and wraps the text as if I pressed Alt+Enter on the keyboard. I would really appreciate some help with the code especially how I replicate the Alt+Enter part of the process as I am totally stuck. Many thanks in anticipation |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to split and wrap text
That's brilliant Tom. Thank you very much.
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I get date/time to wrap (format - wrap text doesn't work)? | Excel Discussion (Misc queries) | |||
Autofit with Merged Cells/Wrap Text Macro Problem | Excel Discussion (Misc queries) | |||
macro to split text in columns | Excel Discussion (Misc queries) | |||
Split text like line wrap into multi columns | Excel Programming | |||
Macro to split mult text in the cell to separate cells | Excel Programming |