Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Lyn Lyn is offline
external usenet poster
 
Posts: 35
Default How do you Find and Replace the word "and" but not the and in "han

I thought there was a - match whole word - option with the Find and Replace
tool but I don't see it now. I'm trying to replace every "and" with "&" but
not affect any words that contain "and" such as "hand" or "bandit".
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default How do you Find and Replace the word "and" but not the and in "han

Be sure to type a single space before and after the and
--
Gary''s Student - gsnu200764


"Lyn" wrote:

I thought there was a - match whole word - option with the Find and Replace
tool but I don't see it now. I'm trying to replace every "and" with "&" but
not affect any words that contain "and" such as "hand" or "bandit".

  #3   Report Post  
Posted to microsoft.public.excel.misc
Lyn Lyn is offline
external usenet poster
 
Posts: 35
Default How do you Find and Replace the word "and" but not the and in

Thanks so much! That did it!

"Gary''s Student" wrote:

Be sure to type a single space before and after the and
--
Gary''s Student - gsnu200764


"Lyn" wrote:

I thought there was a - match whole word - option with the Find and Replace
tool but I don't see it now. I'm trying to replace every "and" with "&" but
not affect any words that contain "and" such as "hand" or "bandit".

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 772
Default How do you Find and Replace the word "and" but not the and in "han

I'm not aware of a way to do that, someone here might enlighten us. What i do
know is that you have an and as a word it will have spaces on both sides so
you can use " and " to get all those. Be warned that anything that starts
with and or has punctuation after it will not get changed.
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Lyn" wrote:

I thought there was a - match whole word - option with the Find and Replace
tool but I don't see it now. I'm trying to replace every "and" with "&" but
not affect any words that contain "and" such as "hand" or "bandit".

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,651
Default How do you Find and Replace the word "and" but not the and in "han

On Thu, 10 Jan 2008 06:36:01 -0800, Lyn wrote:

I thought there was a - match whole word - option with the Find and Replace
tool but I don't see it now. I'm trying to replace every "and" with "&" but
not affect any words that contain "and" such as "hand" or "bandit".


If you do not want to change "and" when it is at the beginning or end of the
string, then

Find what: <spaceand<space
Replace with: <space&<space

If you also want to replace "and" when it occurs at the beginning and end of
the line, then you can use this macro on a cell selection:

==============================
Option Explicit
Sub reReplace()
Dim c As Range
Dim re As Object
'This pattern will replace all "and" including
' those at beginning and end of string
'To omit those at the beginning and end
'Const sPat As String = "\sand\s"
'Const sRepl As String = " & "
Const sPat As String = "\band\b"
Const sRepl As String = "&"

Set re = CreateObject("vbscript.regexp")
re.Pattern = sPat
re.Global = True
re.ignorecase = True
For Each c In Selection
c.Value = re.Replace(c.Value, sRepl)
Next c

End Sub
===================================
--ron
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
Check if cells contain the word "Thailand", return "TRUE" ali Excel Worksheet Functions 7 September 14th 07 09:53 AM
How to replace "#N/A" w "0"when vlookup couldn't find the match? Holly Excel Discussion (Misc queries) 2 July 17th 06 11:48 PM
HELP on "left","right","find","len","substitute" functions serene83 Excel Discussion (Misc queries) 5 June 27th 06 02:23 AM
Replace dialog should put focus on "Find What" not "Replace With" Michael Williams Excel Discussion (Misc queries) 0 May 24th 06 12:45 PM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM


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