Simple array macro works on one sheet only
On Monday, October 24, 2016 at 6:42:38 PM UTC-7, isabelle wrote:
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
Arrrg!
Thanks isabelle, a tiny over look of a tiny dot on my part.
I was using this code (missing a dot)
Sub Greater_Than_Copy_Amend()
Dim MyArr As Variant
Dim i As Long
MyArr = Array("Sheet1", "Sheet2", "Sheet3", "Sheet4")
For i = LBound(MyArr) To UBound(MyArr)
With Sheets(MyArr(i))
.Rows("2:2").Copy Rows("4:4")
End With
Next 'i
End Sub
Thanks again.
Howard
|