

Text(required) - one or more strings to search in.
REGEX FOR NUMBER OF A WORD HOW TO
If you are not very experienced with VBA, this guide may be helpful: How to insert VBA code in Excel.


Paste the code in the VBA editor, and your new RegExpMatch function is ready for use. ReDim arRes(1 To cntInputRows, 1 To cntInputCols)ĪrRes(iInputCurRow, iInputCurCol) = regex.Test(input_range.Cells(iInputCurRow, iInputCurCol).Value) Set regex = CreateObject("VBScript.RegExp") Public Function RegExpMatch(input_range As Range, pattern As String, Optional match_case As Boolean = True) As Variantĭim arRes() As Variant 'array to store the resultsĭim iInputCurRow, iInputCurCol, cntInputRows, cntInputCols As Long 'index of the current row in the source range, index of the current column in the source range, count of rows, count of columns Luckily, Excel's VBA has an inbuilt RegExp object, which you can use in your code like shown below:
