Have managed to sort out the code, but want to exit code after finding "DEPR" one row below DEPR-GENERATORS, the macro must stop, otherwise Insert "DEPR" in front of the text five rows below, but cannot get it to work
see sample data belowCode:Option Explicit Sub Find_Depr () Dim i As Long, ii As Long, iii As Long Dim MyArr As Variant Dim c As Range MyArr = Array("Br1", "Br2", "Br3") 'Your sheet names Application.ScreenUpdating = False For i = LBound(MyArr) To UBound(MyArr) With Sheets(MyArr(i)) ' "DEPR-GENERATORS" will be in Column B1:Bn Set c = .Range("B:B").Find(What:="DEPR-GENERATORS", _ After:=.Range("B1"), _ LookAt:=xlWhole, SearchOrder:=xlByRows, _ SearchDirection:=xlNext) ' Put DEPR in front of the text in the next 5 rows below found Text "DEPR-GENERATORS" For iii = 1 To 1 If c.Offset(iii) Like "Depr" Then Exit Sub End If Else For ii = 1 To 5 c.Offset(ii) = "DEPR" & Trim(c.Offset(ii)) Next ' ii End With Next 'i Application.ScreenUpdating = True End Sub
https://www.dropbox.com/s/ekbr242gcr...nd%20Depr.xlsm




Reply With Quote
Bookmarks