I have written this code to loop though multiple sheets and perform a certain task, but for some reason I'm told that Subscript is out of range at this line:
Sheets(Worksheetss(indexVal)).Range("B4:S25").Select
The complete code can be seen here:
Sub kopierforsatan()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.DisplayStatusBar = False
Dim Worksheet As Variant
Dim Worksheetss As Variant
Dim outputs As Variant
Worksheetss = Array("6_år_lav", "6_år_middel", "6_år_høj", "10_år_høj")
Dim indexVal As Integer
indexVal = 0
For Each Worksheet In Worksheetss
Sheets(Worksheetss(indexVal)).Range("B4:S25").Select
Application.CutCopyMode = False
Selection.Copy
Sheets(Worksheetss(indexVal)).Range("V4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.Copy
Sheets(Worksheetss(indexVal)).Range("V30").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
Sheets(Worksheetss(indexVal)).Range("B54").Select
Sheets(Worksheetss(indexVal)).Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets(Worksheetss(indexVal)).Range("V50").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
Application.CutCopyMode = False
Selection.Copy
Sheets(Worksheetss(indexVal)).Range("Y30").Select
ActiveSheet.Paste
indexVal = indexVal + 1
Next Worksheet
End Sub
What troubles me the most, is that I have used this syntax before with respect to the way the for each loop is constructed.
I Hope someone can see where I have made an error.