Looping the worksheets does not make them active. You want something like this.
Dim WS As Excel.Worksheet
Dim iIndex As Integer
For iIndex = 1 To ActiveWorkbook.Worksheets.count
Set WS = Worksheets(iIndex)
With WS
'Do something here.
.Range("A2").Copy Destination:=.Range("A3:A" & .Cells(.Rows.Count, "B").End(xlUp).Row)
End With
Next iIndex
You could use the ws in your loop, but I always set the object.
For Each ws In ActiveWorkbook.Worksheets
ws.Range("A2").Copy Destination:=ws.Range("A3:A" & Cells(Rows.Count, "B").End(xlUp).Row)
Next ws
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…