ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find Whole Word Only (https://www.excelbanter.com/excel-programming/285112-find-whole-word-only.html)

Lonely[_3_]

Find Whole Word Only
 
Hi All,
I need to replace the text "NS" from all the cells in all the
worksheets of an Excel workbook. I wish to design a macro that can help
me do this along with the use of something that would allow me to do
the "Find Whole Word" option similatr to the one we have in MS Word.

A probable way could be to wrap spaces around the word: " NS " (but
that'll have
trouble with " NS.", " NS, "--any punctuation. But this is still
acceptable.


Please can someone help.
Thanks,
Lonely


---
Message posted from http://www.ExcelForum.com/


Colo

Find Whole Word Only
 
Hi Leonie, Please take a look @
http://www.theofficeexperts.com/foru...0818#post10818


--
Kind Regards
Colo
/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
Colo of 'The Road of The Cell Masters' :)

URL:http://www.interq.or.jp/sun/puremis/...astersLink.htm


/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/



"Lonely" wrote in message
...
Hi All,
I need to replace the text "NS" from all the cells in all the
worksheets of an Excel workbook. I wish to design a macro that can help
me do this along with the use of something that would allow me to do
the "Find Whole Word" option similatr to the one we have in MS Word.

A probable way could be to wrap spaces around the word: " NS " (but
that'll have
trouble with " NS.", " NS, "--any punctuation. But this is still
acceptable.


Please can someone help.
Thanks,
Lonely


---
Message posted from http://www.ExcelForum.com/



fernando cinquegrani[_2_]

Find Whole Word Only
 
"Lonely" ha scritto nel messaggio
...
| Hi All,
| I need to replace the text "NS" from all the cells in all the
| worksheets of an Excel workbook. I wish to design a macro that can help
| me do this along with the use of something that would allow me to do
| the "Find Whole Word" option similatr to the one we have in MS Word.

see also
newsgroup: this
thread: most popular word
date of thread: dec 8, 2003
date of post: today

Sub nsWord()
Dim w As Worksheet, c As Range
Set regexp = CreateObject("VBScript.RegExp")
regexp.Global = True
regexp.IgnoreCase = True
regexp.Pattern = "\bns\b"
For Each w In ActiveWorkbook.Worksheets
Set rng = w.UsedRange
For Each c In rng
c = regexp.Replace(c.Text, "")
Next
Next
End Sub
.f
fernando cinquegrani
Microsoft MVP
http://www.prodomosua.it





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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com