-
Greetings Zuser,
Welcome to vbaexpress!
Try:
[VBA]Option Explicit
Sub exa()
Dim REX As Object '<-- RegExp
Dim lLRow As Long
Dim i As Long
'// Set a reference to Regular Expressions and a simple pattern simply requiring it //
'// to find the word with word boundaries leading/following. If you find you need //
'// to include stuff like "totals", "totalling", etc - the pattern would need changed//
Set REX = CreateObject("VBScript.RegExp")
With REX
.Pattern = "\btotal\b"
.Global = False
.IgnoreCase = True
End With
With Sheet1 '<-- codename or sheet/tab name -->ThisWorkbook.Worksheets ("Sheet1")
lLRow = .Cells(.Rows.Count, 1).End(xlUp).Row
For i = lLRow To 1 Step -1
If REX.Test(.Cells(i, 1).Value) Then
.Cells(i, 1).Characters(Start:=REX.Execute(.Cells(i, 1).Value)(0).FirstIndex + 1, _
Length:=5) _
.Font.FontStyle = "Bold"
.Rows(i + 1).Insert Shift:=xlDown
End If
Next
End With
End Sub[/VBA]
Hope that helps,
Mark
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules