Remove Characters from a cell
I created the User Definable Function. Thank you for that. But I have in
cell A1
"Service 190,000 Klm" and in cell B1 I have "=digitsonly("A1")" but the
answer comes back as "1".
What am I doing wrong?
P.S. I'm new to creating User Definable Functions but I inserted a module
into this sheet after hitting ALT F11. So I think that's not the problem.
Thanks
"Norman Jones" wrote:
Hi Kim,
In a helper column, try using the following User Defined Function:
'=============
Public Function DigitsOnly(sStr As String) As Variant
Dim oRegExp As Object
Set oRegExp = CreateObject("VBScript.RegExp")
With oRegExp
.IgnoreCase = True
.Global = True
oRegExp.Pattern = "\D"
DigitsOnly = oRegExp.Replace(sStr, vbNullString)
End With
End Function
'<<=============
For example:
A1: Service 190,000 Klm
B1: = DigitsOnly("A1") == 190, 000 (with suitable formatting)
---
Regards,
Norman
"Kim" wrote in message
...
Column "A" has a few variations eg:
90,000 K
190,000 Klm Ser
Service 190,000 Klm
I want to remove all characters from each cell to leave in the adjacent
cell
the following
90,000
190,000
190,000
I've done find and replace and recorded a macro but I need to update the
sheet each day and want it to be more automatic. The sheet has around
15000
rows so it takes a while to remove all variations manually, each time it's
updated.
I'd appreciate any help
Thanks
|