A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Find Replace Wildcard



 
 
Thread Tools Display Modes
  #1  
Old September 21st, 2008, 04:52 AM posted to microsoft.public.excel.newusers
DK
external usenet poster
 
Posts: 169
Default Find Replace Wildcard

I am trying to find all number entries that contain any character other then
0-9 and
replace the cell and remove everthing from those cells
  #2  
Old September 21st, 2008, 10:01 AM posted to microsoft.public.excel.newusers
Mike H
external usenet poster
 
Posts: 8,419
Default Find Replace Wildcard

Hi,

This is confusing!

I am trying to find all number entries that contain any character other then
0-9


If you are looking for number cells only what else would be in the cell
other then 0 - 9?

Please provide some example of what you are looking for.

Mike

"dk" wrote:

I am trying to find all number entries that contain any character other then
0-9 and
replace the cell and remove everthing from those cells

  #3  
Old September 21st, 2008, 05:17 PM posted to microsoft.public.excel.newusers
Gord Dibben
external usenet poster
 
Posts: 20,252
Default Find Replace Wildcard

You want to replace the cell with what?

You want to remove everything or just anything that isn't 0-9?

Which is it?

You could use this UDF to remove all but 0-9

Function RemAlpha(str As String) As String
'Remove Alphas from a string
Dim re As Object
Set re = CreateObject("vbscript.regexp")
re.Global = True
re.Pattern = "\D"
RemAlpha = re.Replace(str, "")
End Function

Usage is: =remalphas(cellref)

Or run this macro on a selected range..................

Sub RemoveAlphas()
' Remove alpha characters from all strings.
' except for decimal points
Dim intI As Integer
Dim rngR As Range, rngRR As Range
Dim strNotNum As String, strTemp As String

Set rngRR = Selection.SpecialCells(xlCellTypeConstants, _
xlTextValues)

For Each rngR In rngRR
strTemp = ""
For intI = 1 To Len(rngR.Value)
If Mid(rngR.Value, intI, 1) Like "[0-9,.]" Then 'edit to suit
strNotNum = Mid(rngR.Value, intI, 1)
Else: strNotNum = ""
End If
strTemp = strTemp & strNotNum
Next intI
rngR.Value = strTemp
Next rngR

End Sub


Gord Dibben MS Excel MVP



On Sat, 20 Sep 2008 20:52:00 -0700, dk wrote:

I am trying to find all number entries that contain any character other then
0-9 and
replace the cell and remove everthing from those cells


  #4  
Old September 21st, 2008, 05:32 PM posted to microsoft.public.excel.newusers
DK
external usenet poster
 
Posts: 169
Default Find Replace Wildcard

remove everything if there is any character other then numeric in that cell

You want to replace the cell with what?

You want to remove everything or just anything that isn't 0-9?

Which is it?

You could use this UDF to remove all but 0-9

Function RemAlpha(str As String) As String
'Remove Alphas from a string
Dim re As Object
Set re = CreateObject("vbscript.regexp")
re.Global = True
re.Pattern = "\D"
RemAlpha = re.Replace(str, "")
End Function

Usage is: =remalphas(cellref)

Or run this macro on a selected range..................

Sub RemoveAlphas()
' Remove alpha characters from all strings.
' except for decimal points
Dim intI As Integer
Dim rngR As Range, rngRR As Range
Dim strNotNum As String, strTemp As String

Set rngRR = Selection.SpecialCells(xlCellTypeConstants, _
xlTextValues)

For Each rngR In rngRR
strTemp = ""
For intI = 1 To Len(rngR.Value)
If Mid(rngR.Value, intI, 1) Like "[0-9,.]" Then 'edit to suit
strNotNum = Mid(rngR.Value, intI, 1)
Else: strNotNum = ""
End If
strTemp = strTemp & strNotNum
Next intI
rngR.Value = strTemp
Next rngR

End Sub


Gord Dibben MS Excel MVP



On Sat, 20 Sep 2008 20:52:00 -0700, dk wrote:

I am trying to find all number entries that contain any character other then
0-9 and
replace the cell and remove everthing from those cells



  #5  
Old September 21st, 2008, 06:27 PM posted to microsoft.public.excel.newusers
Gord Dibben
external usenet poster
 
Posts: 20,252
Default Find Replace Wildcard

Sub Remove_If_Not_Nums()
Dim intI As Integer
Dim rngR As Range, rngRR As Range
Dim strNotNum As String, strTemp As String

Set rngRR = Selection.SpecialCells(xlCellTypeConstants, _
xlTextValues)

For Each rngR In rngRR
strTemp = ""
For intI = 1 To Len(rngR.Value)
If Not (Mid(rngR.Value, intI, 1)) Like "[0-9]" Then

rngR.Value = ""
End If
Next
Next

End Sub


Gord

On Sun, 21 Sep 2008 09:32:01 -0700, dk wrote:

remove everything if there is any character other then numeric in that cell

You want to replace the cell with what?

You want to remove everything or just anything that isn't 0-9?

Which is it?

You could use this UDF to remove all but 0-9

Function RemAlpha(str As String) As String
'Remove Alphas from a string
Dim re As Object
Set re = CreateObject("vbscript.regexp")
re.Global = True
re.Pattern = "\D"
RemAlpha = re.Replace(str, "")
End Function

Usage is: =remalphas(cellref)

Or run this macro on a selected range..................

Sub RemoveAlphas()
' Remove alpha characters from all strings.
' except for decimal points
Dim intI As Integer
Dim rngR As Range, rngRR As Range
Dim strNotNum As String, strTemp As String

Set rngRR = Selection.SpecialCells(xlCellTypeConstants, _
xlTextValues)

For Each rngR In rngRR
strTemp = ""
For intI = 1 To Len(rngR.Value)
If Mid(rngR.Value, intI, 1) Like "[0-9,.]" Then 'edit to suit
strNotNum = Mid(rngR.Value, intI, 1)
Else: strNotNum = ""
End If
strTemp = strTemp & strNotNum
Next intI
rngR.Value = strTemp
Next rngR

End Sub


Gord Dibben MS Excel MVP



On Sat, 20 Sep 2008 20:52:00 -0700, dk wrote:

I am trying to find all number entries that contain any character other then
0-9 and
replace the cell and remove everthing from those cells




  #6  
Old September 21st, 2008, 06:46 PM posted to microsoft.public.excel.newusers
DK
external usenet poster
 
Posts: 169
Default Find Replace Wildcard

we get runtime error 104 at
Set rngRR = Selection.SpecialCells(xlCellTypeConstants, _
xlTextValues)

"Gord Dibben" wrote:

Sub Remove_If_Not_Nums()
Dim intI As Integer
Dim rngR As Range, rngRR As Range
Dim strNotNum As String, strTemp As String

Set rngRR = Selection.SpecialCells(xlCellTypeConstants, _
xlTextValues)

For Each rngR In rngRR
strTemp = ""
For intI = 1 To Len(rngR.Value)
If Not (Mid(rngR.Value, intI, 1)) Like "[0-9]" Then

rngR.Value = ""
End If
Next
Next

End Sub


Gord

On Sun, 21 Sep 2008 09:32:01 -0700, dk wrote:

remove everything if there is any character other then numeric in that cell

You want to replace the cell with what?

You want to remove everything or just anything that isn't 0-9?

Which is it?

You could use this UDF to remove all but 0-9

Function RemAlpha(str As String) As String
'Remove Alphas from a string
Dim re As Object
Set re = CreateObject("vbscript.regexp")
re.Global = True
re.Pattern = "\D"
RemAlpha = re.Replace(str, "")
End Function

Usage is: =remalphas(cellref)

Or run this macro on a selected range..................

Sub RemoveAlphas()
' Remove alpha characters from all strings.
' except for decimal points
Dim intI As Integer
Dim rngR As Range, rngRR As Range
Dim strNotNum As String, strTemp As String

Set rngRR = Selection.SpecialCells(xlCellTypeConstants, _
xlTextValues)

For Each rngR In rngRR
strTemp = ""
For intI = 1 To Len(rngR.Value)
If Mid(rngR.Value, intI, 1) Like "[0-9,.]" Then 'edit to suit
strNotNum = Mid(rngR.Value, intI, 1)
Else: strNotNum = ""
End If
strTemp = strTemp & strNotNum
Next intI
rngR.Value = strTemp
Next rngR

End Sub


Gord Dibben MS Excel MVP



On Sat, 20 Sep 2008 20:52:00 -0700, dk wrote:

I am trying to find all number entries that contain any character other then
0-9 and
replace the cell and remove everthing from those cells




  #7  
Old September 21st, 2008, 07:22 PM posted to microsoft.public.excel.newusers
Teethless mama
external usenet poster
 
Posts: 3,722
Default Find Replace Wildcard

Download and install the free add-in Morefunc.xll from:
http://xcell05.free.fr/
....then use this formula

=REGEX.SUBSTITUTE(A1,"\D+")


"dk" wrote:

I am trying to find all number entries that contain any character other then
0-9 and
replace the cell and remove everthing from those cells

  #8  
Old September 21st, 2008, 08:08 PM posted to microsoft.public.excel.newusers
DK
external usenet poster
 
Posts: 169
Default Find Replace Wildcard

this does not empty the cell only removes the none numeric characters

"Teethless mama" wrote:

Download and install the free add-in Morefunc.xll from:
http://xcell05.free.fr/
...then use this formula

=REGEX.SUBSTITUTE(A1,"\D+")


"dk" wrote:

I am trying to find all number entries that contain any character other then
0-9 and
replace the cell and remove everthing from those cells

  #9  
Old September 21st, 2008, 10:57 PM posted to microsoft.public.excel.newusers
Gord Dibben
external usenet poster
 
Posts: 20,252
Default Find Replace Wildcard

I would assume your selection contained no text value cells.

Sub Remove_If_Not_Nums()
Dim intI As Integer
Dim rngR As Range, rngRR As Range
Dim strNotNum As String, strTemp As String
On Error GoTo endit
Set rngRR = Selection.SpecialCells(xlCellTypeConstants, _
xlTextValues)
For Each rngR In rngRR
strTemp = ""
For intI = 1 To Len(rngR.Value)
If Not (Mid(rngR.Value, intI, 1)) Like "[0-9]" Then
rngR.Value = ""
End If
Next
Next
Exit Sub
endit:
MsgBox "only numbers or blanks in selection"
End Sub


Gord

On Sun, 21 Sep 2008 10:46:00 -0700, dk wrote:

we get runtime error 104 at
Set rngRR = Selection.SpecialCells(xlCellTypeConstants, _
xlTextValues)

"Gord Dibben" wrote:

Sub Remove_If_Not_Nums()
Dim intI As Integer
Dim rngR As Range, rngRR As Range
Dim strNotNum As String, strTemp As String

Set rngRR = Selection.SpecialCells(xlCellTypeConstants, _
xlTextValues)

For Each rngR In rngRR
strTemp = ""
For intI = 1 To Len(rngR.Value)
If Not (Mid(rngR.Value, intI, 1)) Like "[0-9]" Then

rngR.Value = ""
End If
Next
Next

End Sub


Gord

On Sun, 21 Sep 2008 09:32:01 -0700, dk wrote:

remove everything if there is any character other then numeric in that cell

You want to replace the cell with what?

You want to remove everything or just anything that isn't 0-9?

Which is it?

You could use this UDF to remove all but 0-9

Function RemAlpha(str As String) As String
'Remove Alphas from a string
Dim re As Object
Set re = CreateObject("vbscript.regexp")
re.Global = True
re.Pattern = "\D"
RemAlpha = re.Replace(str, "")
End Function

Usage is: =remalphas(cellref)

Or run this macro on a selected range..................

Sub RemoveAlphas()
' Remove alpha characters from all strings.
' except for decimal points
Dim intI As Integer
Dim rngR As Range, rngRR As Range
Dim strNotNum As String, strTemp As String

Set rngRR = Selection.SpecialCells(xlCellTypeConstants, _
xlTextValues)

For Each rngR In rngRR
strTemp = ""
For intI = 1 To Len(rngR.Value)
If Mid(rngR.Value, intI, 1) Like "[0-9,.]" Then 'edit to suit
strNotNum = Mid(rngR.Value, intI, 1)
Else: strNotNum = ""
End If
strTemp = strTemp & strNotNum
Next intI
rngR.Value = strTemp
Next rngR

End Sub


Gord Dibben MS Excel MVP



On Sat, 20 Sep 2008 20:52:00 -0700, dk wrote:

I am trying to find all number entries that contain any character other then
0-9 and
replace the cell and remove everthing from those cells





  #10  
Old September 23rd, 2008, 03:45 AM posted to microsoft.public.excel.newusers
DK
external usenet poster
 
Posts: 169
Default Find Replace Wildcard

Can you give us a clear for bth keeping the numeric part of the cell or
removing the whole cell meantme no success

"dk" wrote:

I am trying to find all number entries that contain any character other then
0-9 and
replace the cell and remove everthing from those cells

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:50 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.