Select the range and tryHi there,
I am struggling to get the code for bolding part of a text with a formula.
My sentence is
="That the monkey ate all the appels dated "&TEXT(InRisk,"dd mmmm yyyy")
The date should be in bold
Please help
Sub test()
Dim r As Range, i As Long, m As Object
With CreateObject("VBScript.RegExp")
For i = 1 To 12
myPtn = myPtn & "|" & MonthName(i, False)
Next
.Pattern = "\d{2} (" & Mid(myPtn,2) & ") \d{4}"
.Global = True
For Each r In Selection
If .test(r.Text) Then
r.Value = r.Text : r.Font.Bold = False
For Each m In .execute(r.Text)
r.Characters(m.firstindex + 1, m.length).font.bold = Ture
Next
End If
Next
End With
End Sub
Hi there,
I am struggling to get the code for bolding part of a text with a formula.
My sentence is
="That the monkey ate all the appels dated "&TEXT(InRisk,"dd mmmm yyyy")
The date should be in bold
Please help
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Range("B1")) Is Nothing _
And Not Range("B1").Value = vbNullString _
And Not Target.Count > 1 Then
With Range("A1")
.Value = "That the monkey ate all the appels dated " & Format(Range("B1"), "dd mmmm yyyy")
.Characters(42).Font.Bold = True
End With
End If
End Sub