Home |
Search |
Today's Posts |
#6
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
On Wed, 15 Apr 2009 12:08:14 -0700, MrRJ
wrote: Hi, Is there a way to eliminate wild characters and replacing them with a space. I found this on this site and looks like it could work but need to incoporate the wild characters and in a specific column. Function RemAlpha(str As String) As String With CreateObject("VbScript.RegExp") .Global = True .IgnoreCase = True .Pattern = "[A-Z]" RemAlpha = .Replace(str, vbNullString) End With End Function I appreciate any help you can give. Something like this: ================================== Option Explicit Sub KillWild() Dim rng As Range, c As Range Dim re As Object Set rng = Selection 'or whatever Set re = CreateObject("vbscript.regexp") re.Global = True re.Pattern = "[~!@#$%^&*]" For Each c In rng c.Value = re.Replace(c.Value, " ") Next c End Sub ================================== will remove the characters in your list and replace each one with a <space. In the above, rng is set to "Selection". But you could just as easily set it to a specified range. Also, as written, the function will replace *each* wild character with a space; so if you have several in a row, there will be several spaces; or if there is a space followed by a wild character, there will be several spaces. If you want to only be left with a single space in those instances, make this small change: re.Pattern = "[\s~!@#$%^&*]+" --ron |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Replacing wild card characters in EXCEL | Excel Discussion (Misc queries) | |||
Countif using Wild Card Characters | Excel Worksheet Functions | |||
how can I eliminate the first 3 characters from a cell | Excel Worksheet Functions | |||
Using wild characters for an array | Excel Discussion (Misc queries) | |||
Using wild card characters in array formulas | Excel Worksheet Functions |