Im am trying to find particular text in a cell then format adjacent cells in the same row. In my code below I am trying to search for "*[Tx]*" using Like, however this is formatting all text that contain "T".
Any help much appreciated.
Sub Summary()
' for each cell in column E find [Tx] then format borders
' for each cell in column E find [H] adjacent cell in columns A:A,D:D,F:F,I:I .clear
' Find [Tx] and [H] in column E and clear this text.
Dim i As Long
Dim LC As Integer
LC = Sh1.UsedRange.Columns(ActiveSheet.UsedRange.Columns.Count).Column
Set Sh1 = Sheets("Statement of Profit & Loss")
u1 = Sh1.Range("E" & Rows.Count).End(xlUp).Row
For i = 5 To u1
With Sh1.Cells(i, "E")
If Sh1.Cells(i, "E") = "" Then
Sh1.Rows(i & ":" & i).Clear
ElseIf Sh1.Cells(i, "E") Like "*[H]*" Then
.Offset(, -2).Clear
.Offset(, -4).Clear
.Offset(, 1).Clear
.Offset(, 3).Clear
'does not work
ElseIf Sh1.Cells(i, "E") Like "* [Tx]" Then
With Sh1.Rows(i & ":" & i).borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
End With
With Sh1.Rows(i & ":" & i).borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
End With
End If
End With
Next i
End Sub
Bookmarks