View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
L. Howard L. Howard is offline
external usenet poster
 
Posts: 852
Default Array code troubles

With the three sheets in the array, find the text "DEPR-GENERATORS" in columb B and with the next five rows below "DEPR-GENERATORS", preceed the text in those cells with the text "DEPR".

This code finds the "DEPR-GENERATORS" in columb B and preceeds the five rows each with 3 "DEPR"'s and only on Sheet1.

A sample row before and after code runs:

-COMPUTER EQUIP

and after:

DEPRDEPRDEPR-COMPUTER EQUIP

And only runs on sheet 1.

Thanks.
Howard

Sub AFindIt()

Dim i As Long, ii As Long
Dim MyArr As Variant

MyArr = Array("Sheet1", "Sheet2", "Sheet3")

Application.ScreenUpdating = False

For i = LBound(MyArr) To UBound(MyArr)

With MyArr(i)

' "DEPR-GENERATORS" will be in Column B1:Bn
Cells.Find(What:="DEPR-GENERATORS", After:=ActiveCell, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext).Activate

' Put DEPR in front of the text in the next 5 rows below found text "DEPR-GENERATORS"
For ii = 1 To 5
ActiveCell.Offset(ii) = "DEPR" & Trim(ActiveCell.Offset(ii))
Next ' ii

End With 'MyArr(i)
Next 'i
Application.ScreenUpdating = True
End Sub