Help with MID Function?

R

Ron Rosenfeld

How do I modify to extract only the number?

It occurs to me that you may want something a bit more general.  One way to do
that is to have "pattern" as one of the arguments of the UDF.

That being the case, you could enter the code below but use the following
functions:

To return the digits plus one letter:

=ReMid(A1,"\d+[A-Za-z]")

To return only the digits:

=ReMid(A1,"\d+")

============================
Option Explicit
Function ReMid(str As String, sPattern As String) As String
Dim re As Object, mc As Object
Set re = CreateObject("vbscript.regexp")
re.Pattern = sPattern
If re.test(str) = True Then
    Set mc = re.Execute(str)
    ReMid = mc(0).Value
End If
End Function
========================
--ron

Rick, Ron. Thanks for all of your help. I used the modules and they
work great. I love the support on these groups. Very grreatful.
Thanks again..

You're most welcome. Glad to help. Thanks for the feedback.
--ron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top