Private Sub Worksheet_Calculate()
If (Target.Address(0,0) <> "B1") + (Target.Value = "") Then Exit Sub
Application.EnableEvents = False
With Range("b1")
.Value = .Text
.Font.Bold = False
.Font.Underline = True
End With
With CreateObject("VBScript.RegExp")
.Pattern = "\d{2} (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\D* \d{4}"
.Global = True
If .test(Range("b1").Value) Then
For Each m In .execute(Range("b1").Value))
Range("b1").Characters(m.FirstIndex + 1, m.Length).Font.Bold = True
Range("b1").Characters(m.FirstIndex + 1, m.Length).Font.Underline = False
Next
End If
End With
End Sub
Private Sub Worksheet_Calculate()
Dim i As Long, Ptn As String, m As Object
Application.EnableEvents = False
With Range("b1")
.Value = .Text
.Font.Bold = False
.Font.Underline = True
End With
For i = 1 To 12
Ptn = Ptn & "|" & MonthName(i, False)
Next
With CreateObject("VBScript.RegExp")
.Pattern = "\d{2}\s" & "(" & Mid(Ptn, 2) & ")\s\d{4}"
.Global = True
.IgnoreCase = True
If .test(Range("b1").Value) Then
For Each m In .execute(Range("b1").Value)
Range("b1").Characters(m.FirstIndex + 1, m.Length).Font.Bold = True
Range("b1").Characters(m.FirstIndex + 1, m.Length).Font.Underline = False
Next
End If
End With
Application.EnableEvents = True
End Sub
Hi Mark, It worked perfectly, so how do I get it when the value of B1 is actually in Sheet 2 and needs to be put into sheet 1
With Range("A1")
With ThisWorkbook.Worksheets("Sheet1").Range("A1")
Then also when I need to underline part of a text ex.
The monkeys ate all the apples and/or part of the apples dated 23/03/2009
This should be something like an option button on my userform when I choose All it needs to underline "The monkeys ate all the apples and/or part of the apples dated 23/03/2009" part of the apples should be stroked out. and vise vurse.
Hope you can help me with this.
Basically what my intention is at the end is to cature all the date in Sheet 2 and then give a report based on the information in Sheet 2. Capturing the date will be through a userform
Thx for all the help