The entire code shown in "Case 5" is supposed to RESET Worksheets("Attendance") back to its original state and thus be ready to use for a brand new class that I will teach. When the checkbox(5) is chosen on the userform, this code executes. The part that is not working is a follows:
If x <> 1 Then
cksum = cksum + 1
Worksheets("Attendance").Range("J12:BN14").Copy
Worksheets("Attendance").Range("J12:BN14").Offset(Step, 0).PasteSpecial
Paste:=xlPasteValuesAndNumberFormats
End If
You will note I put a way to check to see if it was going through this routine using the counter "cksum", which it does 19 times. However, it does not copy the range indicated. The target ranges are still empty.
Case 5 'ATTENDANCE Spreadsheet
Worksheets("Attendance").Range("J1:BG7").ClearContents
Worksheets("Attendance").Range("J10:BG10").ClearContents
Worksheets("Attendance").Range("A11:C90").ClearContents 'Student names
Step = 0
ck = 0
cksum = 0
For x = 1 To 20
Worksheets("Attendance").Range("J11:BN11").Offset(Step, 0).ClearContents
** If x <> 1 Then
cksum = cksum + 1
Worksheets("Attendance").Range("J12:BN14").Copy
Worksheets("Attendance").Range("J12:BN14").Offset(Step, 0).PasteSpecial
Paste:=xlPasteValuesAndNumberFormats
End If **
Step = Step + 4
Next x
MsgBox "Copy routine executed " & cksum & " times."
Step = 0
For x = 1 To 20
Worksheets("Attendance").Range("D11").Offset(Step, 0).MergeArea.ClearContents
Step = Step + 3
Next x
'Worksheets("Attendance").Range("K8").Copy
'Worksheets("Attendance").Range("L8:BG8").PasteSpecial
xlPasteFormulasAndNumberFormats
Controls("Checkbox" & k) = False
Case 6
I did not try anything else. The code is question was obtained from another forum and my research indicates the syntax is correct.
Stepis a reserved keyword in VBA, so using it as a variable name is not recommended.