Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8
Default Find and replace # with new line in a cell.

I am copying data into excel where line feeds in the original data are
represented by #. I want to do a find and replace all # with a new line (alt
+ enter) in a cell. How can I do this easily? Or if not easily, with a macro?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 97
Default Find and replace # with new line in a cell.

Hi,

Adapt following macro to your needs :

Sub Macro1()
Cells.Find(What:="#", After:=ActiveCell, LookIn:=xlFormulas,
LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False) _
.Activate
ActiveCell.Replace What:="#", Replacement:=Chr(10),
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
End Sub

HTH
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8
Default Find and replace # with new line in a cell.

Hi Carim,

This doesn't seem to be working.
I need to be able to select a column and search and replace all occurrences
of "#" in ALL populated cells in the column. Is there an equivalent
Cell.ReplaceAll function I can use? I'm afraid my knowledge of creating
Macros is limited to "Record" and "Stop".

Thanks in advance,
R


"Carim" wrote:

Hi,

Adapt following macro to your needs :

Sub Macro1()
Cells.Find(What:="#", After:=ActiveCell, LookIn:=xlFormulas,
LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False) _
.Activate
ActiveCell.Replace What:="#", Replacement:=Chr(10),
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
End Sub

HTH

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 97
Default Find and replace # with new line in a cell.

Hi,

Select a range and then run macro ...

Sub Macro1()
Dim cell As Range
For Each cell In Selection
Cells.Find(What:="#", After:=cell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False) _
.Activate
cell.Replace What:="#", Replacement:=Chr(10), LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Next cell
Range("A1").Select
End Sub

HTH
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8
Default Find and replace # with new line in a cell.

Works superbly. Thanks.

"Carim" wrote:

Hi,

Select a range and then run macro ...

Sub Macro1()
Dim cell As Range
For Each cell In Selection
Cells.Find(What:="#", After:=cell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False) _
.Activate
cell.Replace What:="#", Replacement:=Chr(10), LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Next cell
Range("A1").Select
End Sub

HTH



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 97
Default Find and replace # with new line in a cell.

Glad it fixed your problem ...

Thanks for the feedback
  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Find and replace # with new line in a cell.

Another option is to replace all the # with that newline in one command.

Record a macro when you:
select all the cells
edit|Replace
what: #
with: ctrl-j
replace all



rmellison wrote:

I am copying data into excel where line feeds in the original data are
represented by #. I want to do a find and replace all # with a new line (alt
+ enter) in a cell. How can I do this easily? Or if not easily, with a macro?


--

Dave Peterson
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
Find and Replace where there are line breaks radellaf Excel Discussion (Misc queries) 3 August 24th 07 02:45 PM
find-replace box should not float but be fixed line on tool bar fnortne Excel Worksheet Functions 0 July 19th 05 07:13 PM
How can I do a find and replace for a cell that has multiple line. yrat Excel Discussion (Misc queries) 1 April 19th 05 03:48 PM
Adding line breaks by using find and replace soozie Excel Discussion (Misc queries) 3 March 6th 05 11:04 PM
Find/Replace carriage return & line feed characters in Excel. Mary Cullen Excel Worksheet Functions 1 January 4th 05 07:39 PM


All times are GMT +1. The time now is 03:27 PM.

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

About Us

"It's about Microsoft Excel"