I am trying to implement Regular Expressions in Excel 2010 on a mac, but with any formulas and data all I get is #VALUE errors
Here is my implementation in a module:
Function RegExp1(ReplaceIn, ReplaceWhat As String, _
ReplaceWith As String, Optional IgnoreCase As Boolean = False)
Dim re As Object
Set re = CreateObject("VBScript.RegExp")
re.IgnoreCase = IgnoreCase
re.Pattern = ReplaceWhat
re.Global = True
RegExp1 = re.Replace(ReplaceIn, ReplaceWith)
End Function
And then in the cell I try:
=RegExp1(D2,"(PR2001\.)(\d)","$100$2")
All of this is executing on cells similar to:
PR2001.1
PR2001.2
PR2001.3
etc… I am trying to add zeros in between the last digit and period to format for easier sorting. Any help would be appreciated
Excel X does not support VBScript, so you will not be able to do this. The functon works and the expression is fine, btw.
What I can suggest to you is to write a function using InStrRev (actually this is a good solution even if you could use regexp).