I need replace text between {} with "class"
Examle -- {aaaaaaaaaa} 4-6pm and {bbbbbbbbbb} 6-8 pm
i need to replace above value class 4-6pm and class 6-8pm
Sample file is alos attached.
Here is my macro:-
Option Explicit
Sub BoldTextString()
Dim s As String
Dim r As Range, c As Range
Dim re As Object, mc As Object, m As Object
Dim i As Long
Set r = Selection
Set re = CreateObject("vbscript.regexp")
re.Global = True
re.ignorecase = True
For Each c In r
re.Pattern = "{[\s\S]+?(?=})"
Set mc = re.Execute(c.Text)
re.Pattern = "{|}"
c.Value = re.Replace(c.Text, "")
i = 0
For Each m In mc
With c.Characters(m.firstindex + 1 - 3 * i, _
m.Length - 1)
.insert = ("class")
.Font.Bold = True
.Font.Underline = True
.Font.Size = 11
End With
i = i + 1
Next m
Next c
End Sub
Thanks in advance.
REgards
Sourabh
Bookmarks