Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Ignore punctuation

Hi,
Is there a way to ignore all punctuation and special characters when
comparing two string expressions?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Ignore punctuation

I can't think of anything that does that. The worksheet function clean can
remove non-printing characters. I think you would need to write a UDF to do
it.

--
Regards,
Tom Ogilvy

"Purnima" wrote in message
...
Hi,
Is there a way to ignore all punctuation and special characters when
comparing two string expressions?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Ignore punctuation


first strip the strings of "unwanted" characers..
before you compare..

Option Compare Binary

Function StripString(s$)
'Note: LIKE depends on option compare.see VBA help.
Dim i&, r$, c$
Const mask = "[A-Za-z0-9]"
For i = 1 To Len(s)
c = Mid$(s, i, 1)
If c Like mask Then r = r & c
Next
StripString = r
End Function

then compare like..

If StrComp(StripString(MyString1), _
StripString(myString2)) = 0 Then
MsgBox "stripped compare OK"
ElseIf StrComp(StripString(MyString1), _
StripString(myString2), vbTextCompare) = 0 Then
MsgBox "stripped compare CaseInsensitive OK"
Else
MsgBox "NOT"
End If







--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Purnima wrote :

Hi,
Is there a way to ignore all punctuation and special characters when
comparing two string expressions?

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
Ignoring punctuation when sorting Dave[_4_] Excel Discussion (Misc queries) 1 September 28th 07 02:28 AM
remove punctuation from address Mary New Users to Excel 3 August 29th 06 01:53 PM
Punctuation English/Danish Lise Setting up and Configuration of Excel 1 July 31st 06 08:48 PM
Remove Punctuation? kcoakley Excel Worksheet Functions 6 June 2nd 06 04:46 AM
How to I change punctuation spacing Two space-jam after punctuation Excel Discussion (Misc queries) 1 January 11th 06 01:09 AM


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