User Function causing Excel to run slow

I have a user function that I have been using to seperate numbers out of a text string but I have noticed that when the workbook is open that contains the user function, excel runs really slow, every alteration I make in a cell takes ~ 5seconds to calculate, even just entering a value into the cell. The user function is pasted in below.

Function Sep(txt As String, flg As Boolean) As String
With CreateObject(“VBScript.RegExp”)
    .Pattern = IIf(flg = True, “d+”, “D+”)
    .Global = True
    Sep = .Replace(txt, “”)
End With
End Function

I canot remeber eactly where I got this from but it does work, just slows everything else dowm to a point that I have to comment it out when not in use.

Thanks,

Tony

By: Tony Cox

Leave a Reply

Your email address will not be published. Required fields are marked *