I need some help , i feel i am very close , i have 31 sheets and have multiple separate ranges of cells i am looking to clear with an activex command button.
Below is a line of code that actually works very well.
Private Sub CommandButton1_Click()
If MsgBox("Are you sure? Cannot undo.", vbYesNo) = vbNo Then Exit Sub
'Updateby Extendoffice
Sheet2.Range("B7:T18").ClearContents
Sheet2.Range("B21:T32").ClearContents
Sheet2.Range("B40:T51").ClearContents
Sheet2.Range("B54:T65").ClearContents
Sheet2.Range("B73:T84").ClearContents
Sheet2.Range("B87:T98").ClearContents
Sheet2.Range("B107:T118").ClearContents
Sheet2.Range("B121:T132").ClearContents
Sheet3.Range("B7:T18").ClearContents
Sheet3.Range("B21:T32").ClearContents
Sheet3.Range("B40:T51").ClearContents
Sheet3.Range("B54:T65").ClearContents
Sheet3.Range("B73:T84").ClearContents
Sheet3.Range("B87:T98").ClearContents
Sheet3.Range("B107:T118").ClearContents
Sheet3.Range("B121:T132").ClearContents
End Sub
BUT , what i want to do is for each sheet's array of cells (IE: B7:T18 , B21:T32, ETC) consolidate them to one line of code (instead of 8 lines of code for each sheet), to something like this
Private Sub CommandButton1_Click()
If MsgBox("Are you sure? Cannot undo.", vbYesNo) = vbNo Then Exit Sub
'Updateby Extendoffice
Sheets("Sheet1").Array.Range("B7:T18", "B21:T32", "B40:T51", "B54:T65", "B73:T84", "B87:T98", "B107:T118", "B121:T132").ClearContents
Sheets("Sheet2").Array.Range("B7:T18", "B21:T32", "B40:T51", "B54:T65", "B73:T84", "B87:T98", "B107:T118", "B121:T132").ClearContents
ETC
End Sub
If anyone can help me out i would greatly appreciate it , i feel i am close , ALSO note the above consolidated code when used states "Run-time error '9': Subscript out of range"
Below is a line of code that actually works very well.
Private Sub CommandButton1_Click()
If MsgBox("Are you sure? Cannot undo.", vbYesNo) = vbNo Then Exit Sub
'Updateby Extendoffice
Sheet2.Range("B7:T18").ClearContents
Sheet2.Range("B21:T32").ClearContents
Sheet2.Range("B40:T51").ClearContents
Sheet2.Range("B54:T65").ClearContents
Sheet2.Range("B73:T84").ClearContents
Sheet2.Range("B87:T98").ClearContents
Sheet2.Range("B107:T118").ClearContents
Sheet2.Range("B121:T132").ClearContents
Sheet3.Range("B7:T18").ClearContents
Sheet3.Range("B21:T32").ClearContents
Sheet3.Range("B40:T51").ClearContents
Sheet3.Range("B54:T65").ClearContents
Sheet3.Range("B73:T84").ClearContents
Sheet3.Range("B87:T98").ClearContents
Sheet3.Range("B107:T118").ClearContents
Sheet3.Range("B121:T132").ClearContents
End Sub
BUT , what i want to do is for each sheet's array of cells (IE: B7:T18 , B21:T32, ETC) consolidate them to one line of code (instead of 8 lines of code for each sheet), to something like this
Private Sub CommandButton1_Click()
If MsgBox("Are you sure? Cannot undo.", vbYesNo) = vbNo Then Exit Sub
'Updateby Extendoffice
Sheets("Sheet1").Array.Range("B7:T18", "B21:T32", "B40:T51", "B54:T65", "B73:T84", "B87:T98", "B107:T118", "B121:T132").ClearContents
Sheets("Sheet2").Array.Range("B7:T18", "B21:T32", "B40:T51", "B54:T65", "B73:T84", "B87:T98", "B107:T118", "B121:T132").ClearContents
ETC
End Sub
If anyone can help me out i would greatly appreciate it , i feel i am close , ALSO note the above consolidated code when used states "Run-time error '9': Subscript out of range"