I have a macro which successfully copies data from one column, pastes it into the next empty column in a specific range and then deletes cell contents in another range.
It only works on the open worksheet.
I have tried to add a loop to cycle through a selection of worksheets within the workbook and, whilst the macro runs, it still only performs the procedure on the worksheet that is open.
Can anyone help me to make it run on each of the worksheets listed in the array?
Sub CopyPasteEoY_OtherSubjects()
'
' CopyPaste Macro
'
Dim Sh As Variant 'Sh = All Foundation Subjects sheets
Dim targetRng As Excel.Range
Dim destRng As Excel.Range
Dim objsRng As Excel.Range
Set targetRng = Range("AU4:AU103")
Set destRng = Range("V4:AB103")
Set objsRng = Range("AC4:AT103")
Application.ScreenUpdating = False
For Each Sh In Array("Art", "Computing", "Design Technology", "Geography", "History", "MFL", "Music", "PE", "RE", "Science")
With destRng
Set destRng = .Cells(.Columns.Count).End(Excel.xlToLeft).Offset(0, 1).Resize(targetRng.Rows.Count, targetRng.Columns.Count)
destRng.Value = targetRng.Value
With objsRng
.ClearContents
End With
End With
Next Sh
Application.ScreenUpdating = True
End Sub
Many thanks.
Rangeobject. That is, puttargetRng,destRng, andobjsRngin the loop, and set them asSet targetRng = worksheets(Sh).Range("AU4:AU103")etc. - newacc2240