Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Jamie Furlong
 
Posts: n/a
Default Partial search and replace?

Problem:
Loads of descriptions came in trimmed at 64 chars. At the end of most items,
there is the line "This includes free delivery".
But most times, it's been chopped. So it might be
This includes free delivery
This includes fre
Thi
etc. So I don't know the left or right chars to trim to neaten this up.
So I thought wildcard or regex find and replace would do, but it doesn't
seem to want to work like that with me! I've tried searching for phrases
like "partial find and replace" on this forum, but to no avail. I've got
4500 lines to do, so I'd rather not do it by hand!

Thanks.


  #2   Report Post  
Ian
 
Posts: n/a
Default

Assuming the data you want to keep always ends in a period "." , this should
work for you.

Sub Trim_to_period()
c = 1 ' Change to suit column number (A=1, B=2 etc.)
For r = 1 To 7 ' Change to suit row range
Do While Right(Cells(r, c), 1) < "."
If (Cells(r, c) = "") Then GoTo continue
Cells(r, c).Value = Left(Cells(r, c), Len(Cells(r, c)) - 1)
Loop
continue:
Next
End Sub

--
Ian
--
"Jamie Furlong" wrote in message
...
Problem:
Loads of descriptions came in trimmed at 64 chars. At the end of most
items, there is the line "This includes free delivery".
But most times, it's been chopped. So it might be
This includes free delivery
This includes fre
Thi
etc. So I don't know the left or right chars to trim to neaten this up.
So I thought wildcard or regex find and replace would do, but it doesn't
seem to want to work like that with me! I've tried searching for phrases
like "partial find and replace" on this forum, but to no avail. I've got
4500 lines to do, so I'd rather not do it by hand!

Thanks.



  #3   Report Post  
Martin P
 
Posts: n/a
Default

If the "This includes" part is always within brackets:
=SUBSTITUTE(A1, MID(A1,FIND("(",A1),LEN(A1)-FIND("(",A1)+1),"")
and copy down.

"Jamie Furlong" wrote:

Problem:
Loads of descriptions came in trimmed at 64 chars. At the end of most items,
there is the line "This includes free delivery".
But most times, it's been chopped. So it might be
This includes free delivery
This includes fre
Thi
etc. So I don't know the left or right chars to trim to neaten this up.
So I thought wildcard or regex find and replace would do, but it doesn't
seem to want to work like that with me! I've tried searching for phrases
like "partial find and replace" on this forum, but to no avail. I've got
4500 lines to do, so I'd rather not do it by hand!

Thanks.



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
Search and replace Subu Excel Worksheet Functions 4 June 9th 05 07:01 PM
Partial replace Sept New Users to Excel 2 May 25th 05 09:39 AM
Search and Replace Rebecca Excel Discussion (Misc queries) 1 May 14th 05 11:53 AM
Search and Replace Question Rebecca New Users to Excel 1 April 11th 05 04:49 AM
GLOBAL search and replace Rebecca New Users to Excel 2 February 26th 05 12:30 AM


All times are GMT +1. The time now is 12:56 AM.

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"