Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Macro to locate/modify text

Hello all,

I have an excel document that has a series of cells in an excel sheet
that have some data in them. Each cell has a format similar to this:

N/C 1) Sample text N/C 2) More sample text N/C 3) ........

Each cell could have up to 5 pieces of data in it. What I need to do
is have a macro that will step through each cell and locate each piece
higher than N/C 1) and insert an Alt+Enter before it. The resulting
cell would look like this:

N/C 1) Sample text
N/C 2) More sample text
N/C 3) ........

This would make it much easier to read and analyze. The reason I need
to do this is a report needs to be exported into excel on a regular
basis, and unfortunately there is no way to export the text in any
other way. Therefore, I need a macro that can clean it up a bit.

Can anyone help me with this?

Thanks in advance,

-NVB

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Macro to locate/modify text

Sub fixData()
Intersect(Selection, ActiveSheet.UsedRange).Select
Selection.Replace What:="N/C", _
Replacement:=Chr(10) & "N/C", _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
MatchCase:=False
For Each cell In Selection
If Left(cell, 1) = Chr(10) Then
cell.Value = Right(cell, Len(cell) - 1)
End If
Next
Selection.WrapText = True
Selection.ColumnWidth = 50
Selection.EntireColumn.AutoFit
Rows.AutoFit
End Sub

--
Regards,
Tom Ogilvy


"Nate" wrote:

Hello all,

I have an excel document that has a series of cells in an excel sheet
that have some data in them. Each cell has a format similar to this:

N/C 1) Sample text N/C 2) More sample text N/C 3) ........

Each cell could have up to 5 pieces of data in it. What I need to do
is have a macro that will step through each cell and locate each piece
higher than N/C 1) and insert an Alt+Enter before it. The resulting
cell would look like this:

N/C 1) Sample text
N/C 2) More sample text
N/C 3) ........

This would make it much easier to read and analyze. The reason I need
to do this is a report needs to be exported into excel on a regular
basis, and unfortunately there is no way to export the text in any
other way. Therefore, I need a macro that can clean it up a bit.

Can anyone help me with this?

Thanks in advance,

-NVB


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
Locate data macro Malcolm McM[_2_] Excel Discussion (Misc queries) 2 April 26th 10 11:43 PM
How do I locate cells that contain a certain text? EZ-XLS Excel Worksheet Functions 2 May 4th 09 09:41 PM
Locate and count the recurrences of a text string Trish2 Excel Discussion (Misc queries) 1 March 8th 06 03:02 PM
locate shapes with specified text inside lvcha.gouqizi Excel Programming 4 October 25th 05 02:23 PM
Using IF to locate specific text string value Metalmaiden Excel Programming 9 October 10th 04 12:26 AM


All times are GMT +1. The time now is 12:35 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"