i am working with a excel spreadsheet that has been converted from PDF. The conversion rendered merged cells in a column that has percentages separated by 5 spaces (i.e. 100% 50%). Is it possible to use RegEx to extract "50%" and place it in next column ("C")? An un-merged action frees up a column where I would like to store the second percentage (50%).LEN discovered 12 characters. Generally, I'd like to, Take the right side of columns B & E place that data in it's respective adjacent column. So far, all I have succeeded in is getting "Compile error: User-defined type not defined". I've swithced expressions with "Set regex = CreateObject("vbscript.regexp") - but to no success.
Below is the code I have tried for Column B.
Below is the code I have tried for Column B.
VBA Code:
Sub RegExTest()
'CoInsurance "In" & "Out" percentages
Dim arr As Variant
arr = perNames.Range("B4").CurrentRegion.Columns(2).Value
'Create Regular Experession objevt
Dim regEx As New RegExp
regEx.Global = True
regEx.Pattern = "[0-9]+"
Dim text As Variant
Dim mc As MatchCollection, row As Long
row = 1
'Read though each of the strings
For Each text In arr
If regEx.Test(text) = True Then
Set mc = regEx.Execute(text)
perNames.Range("C" & row).Value = mc(0)
perNames.Range("D" & row).Vaue = mc(1)
End If