View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
isabelle isabelle is offline
external usenet poster
 
Posts: 99
Default Simple array macro works on one sheet only

Hi,

For i = LBound(MyArr) To UBound(MyArr)
With Sheets(MyArr(i))
.Rows("2:2").Copy .Rows("4:4")
End With
Next 'i

isabelle

Le 2016-10-24 Ã* 21:11, L. Howard a écrit :

This in a standard module only works on the sheet from which it is called.

Should it not do all four sheets run from any sheet?

Howard

Sub Plain_Copy()
Dim MyArr As Variant
Dim i As Long


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


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

Sheets(MyArr(i)).Rows("2:2").Copy Rows("4:4")

Next 'i

End Sub