I have a reset button on a user forum to reset the workbook to its original state. Certain parts of the code do not work, and I am not sure why. I have placed the two sections of the code that doesn't work in comments.
FIRST half of the code. Problem #1: It clears everything on sheet1, but then the debugger runs when it gets to sheet2, and gives a range error.
Second half of the code. Problem #2: It will place the formula on sheets 3-32, but it will not clear the contents in the cells.
FIRST half of the code. Problem #1: It clears everything on sheet1, but then the debugger runs when it gets to sheet2, and gives a range error.
Code:
Private Sub CommandButton1_Click()
Sheet1.Range("B5:C34").Select
Selection.ClearContents
Sheet1.Range("E10, E12, E14, E16").Select
Selection.ClearContents
Sheet1.Range("B5").Select
'Sheet2.Range("C5:E12").Select
'Selection.ClearContents
'Sheet2.Range("C5").Select
Second half of the code. Problem #2: It will place the formula on sheets 3-32, but it will not clear the contents in the cells.
Code:
Dim i As Integer
For i = 3 To 32
Sheets(i).Range("D40").FormulaR1C1 = "='Weekly Setup'!R2C2"
'Sheets(i).Range("C8:C29").Select
'Selection.ClearContents
Next i
Unload Me
End Sub