Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 109
Default Eliminate wild characters

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.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,722
Default Eliminate wild characters

Select the range/column you want to deal with.

Open Find&Replace (Ctrl+H)

Use a tilde in front of wildcard (e.g., ~* finds the * symbol)
In replace, input a single space " "
Under options, make sure you are looking in sheet, not workbook.
Replace all.

Repeat as needed for other various wildcard symbols.
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"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.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Eliminate wild characters

Hi,

And in this context what is your definition of 'wild characters'?

Mike

"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.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 109
Default Eliminate wild characters

Luke,
Thanks for your quick reply. I wasn't clearer before, I am looking for a
VBA code to do this. Also, I want to replace all wild characters, like these
~!@#$%^&*()

Any ideas?

"Luke M" wrote:

Select the range/column you want to deal with.

Open Find&Replace (Ctrl+H)

Use a tilde in front of wildcard (e.g., ~* finds the * symbol)
In replace, input a single space " "
Under options, make sure you are looking in sheet, not workbook.
Replace all.

Repeat as needed for other various wildcard symbols.
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"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.

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 109
Default Eliminate wild characters

Mike,
Sorry if I was not clear before.
I am looking for a VBA code to replace wild characters ~!@#$%^&*() with a
space. Does that help?



"Mike H" wrote:

Hi,

And in this context what is your definition of 'wild characters'?

Mike

"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.



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,651
Default Eliminate wild characters

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
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
Replacing wild card characters in EXCEL arjay010 Excel Discussion (Misc queries) 2 June 29th 07 02:07 AM
Countif using Wild Card Characters nebb Excel Worksheet Functions 2 February 11th 06 12:14 AM
how can I eliminate the first 3 characters from a cell brantty Excel Worksheet Functions 3 September 28th 05 10:01 PM
Using wild characters for an array Steven Excel Discussion (Misc queries) 2 February 9th 05 04:29 PM
Using wild card characters in array formulas PJB Shark Excel Worksheet Functions 3 January 19th 05 03:09 PM


All times are GMT +1. The time now is 02:37 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"