Thanks Draw border above specific text string
Hello Mark,
Works like a charm. Thanks a million. You have saved me lots of hours
Rashid Khan
"Mark Thorpe" wrote in message
...
I think you just need to check each cell using the InStr function to see
if
the string in D1 is a substring. See if this works for you:
Sub Macro1()
Dim sSearch As String
Dim lRowCount As Long
Dim iColCount As Integer
Dim lRow As Long
Dim iCol As Integer
lRowCount = ActiveSheet.UsedRange.Rows.Count
iColCount = ActiveSheet.UsedRange.Columns.Count
sSearch = Cells(1, 4).Value
For lRow = 2 To lRowCount
For iCol = 1 To iColCount
If InStr(Cells(lRow, iCol).Value, sSearch) 0 Then
With Cells(lRow, iCol).Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 3
End With
End If
Next iCol
Next lRow
End Sub
|