Newbie repeat question
Below is code that stores the cell address of the first found text, and
then sets up a loop to do the border stuff and at the end calls the
Findnext method and checks the address of the next found text with the
first.
Sub Myfind()
Dim rng As Range
Dim result As Range
Dim firstAddress As String
Set rng = ThisWorkbook.Worksheets("sheet1").Range("A:F")
With rng
Set result = .Find("ATM", After:=ActiveCell,
LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False _
, SearchFormat:=False)
If Not result Is Nothing Then
firstAddress = result.Address 'get address of first
result
Do
With result.EntireRow
With .Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
.Borders(xlEdgeBottom).LineStyle = xlNone
.Borders(xlEdgeRight).LineStyle = xlNone
.Borders(xlInsideVertical).LineStyle = xlNone
End With
Set result = .FindNext(result)
Loop While Not result Is Nothing And result.Address <
firstAddress
End If
End With
End Sub
|