Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Macro to split and wrap text

That's brilliant Tom. Thank you very much.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I get date/time to wrap (format - wrap text doesn't work)? Alex Excel Discussion (Misc queries) 3 April 4th 23 02:29 PM
Autofit with Merged Cells/Wrap Text Macro Problem elfmajesty Excel Discussion (Misc queries) 3 May 25th 06 06:32 PM
macro to split text in columns nshanmugaraj Excel Discussion (Misc queries) 1 March 3rd 06 02:03 PM
Split text like line wrap into multi columns 1scant Excel Programming 4 February 16th 06 07:53 PM
Macro to split mult text in the cell to separate cells floss Excel Programming 2 June 5th 04 06:17 PM


All times are GMT +1. The time now is 04:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"