I've recorded a Macro in which I select several ranges of cells within a worksheet to be cleared, clear them, then save. It seems straight forward enough, and I've done this multiple times before on other duplicate worksheets without issue; however, I've done this several times on this sheet, but every time results in the same error for the same line in the code for this particular worksheet.
I don't know enough about VBA (hense why I recorded the macro rather than writing it) to trouble shoot it. I could use some help. The macro is tied to a button, and appears when I click the button. Here's the code, and the line that is highlighted when the error pops up: Compile error: Argument not optional
Sub Sheet_Clear()
'
' Sheet_Clear Macro
' Resets all data entry cells back to zero. Macro created by J. Streck on 10/21/2010.
'
Dim nResult As Long
nResult = MsgBox( _
Prompt:="Are you sure you want to clear your sheet? Click YES to clear, or NO to stop.", _
Buttons:=vbYesNo)
If nResult = vbNo Then
Exit Sub
End If
Range("Q47:R65,BF47:BF65,CS47:CS65,EF47:EF65,BD67,CQ67,ED67,FQ67").Select
Range("FQ67").Activate
Range( _
"Q47:R65,BF47:BF65,CS47:CS65,EF47:EF65,BD67,CQ67,ED67,FQ67,Q70:R83,BF70:BF83,CS70:CS83,EF70:EF83,BD85,CQ85,ED85,FQ85" _
).Select
Range("FQ85").Activate
Range( _
"Q47:R65,BF47:BF65,CS47:CS65,EF47:EF65,BD67,CQ67,ED67,FQ67,Q70:R83,BF70:BF83,CS70:CS83,EF70:EF83,BD85,CQ85,ED85,FQ85,Q88:R101,BF88:BF101,CS88:CS101,EF88:EF101,BD103,CQ103,ED103,FQ103" _
).Select
Range("FQ103").Activate
Union(Range( _
"Q47:R65,BF47:BF65,CS47:CS65,EF47:EF65,BD67,CQ67,ED67,FQ67,Q70:R83,BF70:BF83,CS70:CS83,EF70:EF83,BD85,CQ85,ED85,FQ85,Q88:R101,BF88:BF101,CS88:CS101,EF88:EF101,BD103,CQ103,ED103,FQ103,Q106:R119,BF106:BF119,CS106:CS119,EF106:EF119,BD121,CQ121,ED121,FQ121" _
)).Select
Range("FQ121").Activate
Union(Range( _
"FT47:FU65,GC47:GD65,GK47:GL65,GS47:GT65,HA47:HB65,HI47:HJ65,Q47:R65,BF47:BF65,CS47:CS65,EF47:EF65,BD67,CQ67,ED67,FQ67,Q70:R83,BF70:BF83,CS70:CS83,EF70:EF83,BD85,CQ85,ED85,FQ85,Q88:R101,BF88:BF101,CS88:CS101,EF88:EF101,BD103,CQ103,ED103,FQ103,Q106:R119" _
), Range("CS106:CS119,EF106:EF119,BD121,CQ121,ED121,FQ121")).Select
Range("HI47").Activate
Union(Range( _
"FT47:FU65,GC47:GD65,GK47:GL65,GS47:GT65,HA47:HB65,HI47:HJ65,HQ47:HR65,Q47:R65,BF47:BF65,CS47:CS65,EF47:EF65,BD67,CQ67,ED67,FQ67,Q70:R83,BF70:BF83,CS70:CS83,EF70:EF83,BD85,CQ85,ED85,FQ85,Q88:R101,BF88:BF101,CS88:CS101,EF88:EF101,BD103,CQ103,ED103,FQ103" _
), Range("BF106:BF119,CS106:CS119,EF106:EF119,BD121,CQ121,ED121,FQ121")).Select
Range("HQ47").Activate
Union(Range( _
"FT47:FU65,GC47:GD65,GK47:GL65,GS47:GT65,HA47:HB65,HI47:HJ65,HQ47:HR65,FT70:FU83,GC70:GD83,GK70:GL83,GS70:GT82,GS83:GT83,HA70:HB83,Q47:R65,BF47:BF65,CS47:CS65,EF47:EF65,BD67,CQ67,ED67,FQ67,Q70:R83,BF70:BF83,CS70:CS83,EF70:EF83,BD85,CQ85,ED85,FQ85,Q88:R101" _
), Range( _
"EF88:EF101,BD103,CQ103,ED103,FQ103,Q106:R119,BF106:BF119,CS106:CS119,EF106:EF119,BD121,CQ121,ED121,FQ121" _
)).Select
Range("HA70").Activate
Union(Range( _
"FT47:FU65,GC47:GD65,GK47:GL65,GS47:GT65,HA47:HB65,HI47:HJ65,HQ47:HR65,FT70:FU83,GC70:GD83,GK70:GL83,GS70:GT82,GS83:GT83,HA70:HB83,HI70:HJ83,HQ70:HR83,Q47:R65,BF47:BF65,CS47:CS65,EF47:EF65,BD67,CQ67,ED67,FQ67,Q70:R83,BF70:BF83,CS70:CS83,EF70:EF83,BD85,CQ85" _
), Range( _
"BF88:BF101,CS88:CS101,EF88:EF101,BD103,CQ103,ED103,FQ103,Q106:R119,BF106:BF119,CS106:CS119,EF106:EF119,BD121,CQ121,ED121,FQ121" _
)).Select
Range("HQ70").Activate
Union(Range( _
"FT47:FU65,GC47:GD65,GK47:GL65,GS47:GT65,HA47:HB65,HI47:HJ65,HQ47:HR65,FT70:FU83,GC70:GD83,GK70:GL83,GS70:GT82,GS83:GT83,HA70:HB83,HI70:HJ83,HQ70:HR83,FT88:FU101,GC88:GD101,GK88:GL101,GS88:GT101,HA88:HB101,Q47:R65,BF47:BF65,CS47:CS65,EF47:EF65,BD67,CQ67,ED67" _
), Range( _
"BD85,CQ85,ED85,FQ85,Q88:R101,BF88:BF101,CS88:CS101,EF88:EF101,BD103,CQ103,ED103,FQ103,Q106:R119,BF106:BF119,CS106:CS119,EF106:EF119,BD121,CQ121,ED121,FQ121" _
)).Select
Range("HA88").Activate
Union(Range( _
"FT47:FU65,GC47:GD65,GK47:GL65,GS47:GT65,HA47:HB65,HI47:HJ65,HQ47:HR65,FT70:FU83,GC70:GD83,GK70:GL83,GS70:GT82,GS83:GT83,HA70:HB83,HI70:HJ83,HQ70:HR83,FT88:FU101,GC88:GD101,GK88:GL101,GS88:GT101,HA88:HB101,HI88:HJ100,HI101:HJ101,HQ88:HR101,Q47:R65,BF47:BF65" _
), Range( _
"BF70:BF83,CS70:CS83,EF70:EF83,BD85,CQ85,ED85,FQ85,Q88:R101,BF88:BF101,CS88:CS101,EF88:EF101,BD103,CQ103,ED103,FQ103,Q106:R119,BF106:BF119,CS106:CS119,EF106:EF119,BD121,CQ121,ED121,FQ121" _
)).Select
Range("HQ88").Activate
Union(Range( _
"FT47:FU65,GC47:GD65,GK47:GL65,GS47:GT65,HA47:HB65,HI47:HJ65,HQ47:HR65,FT70:FU83,GC70:GD83,GK70:GL83,GS70:GT82,GS83:GT83,HA70:HB83,HI70:HJ83,HQ70:HR83,FT88:FU101,GC88:GD101,GK88:GL101,GS88:GT101,HA88:HB101,HI88:HJ100,HI101:HJ101,HQ88:HR101,FT106:FU119" _
), Range( _
"ED67,FQ67,Q70:R83,BF70:BF83,CS70:CS83,EF70:EF83,BD85,CQ85,ED85,FQ85,Q88:R101,BF88:BF101,CS88:CS101,EF88:EF101,BD103,CQ103,ED103,FQ103,Q106:R119,BF106:BF119,CS106:CS119,EF106:EF119,BD121,CQ121,ED121,FQ121" _
)).Select
Range("GK106").Activate
Union(Range( _
"FT47:FU65,GC47:GD65,GK47:GL65,GS47:GT65,HA47:HB65,HI47:HJ65,HQ47:HR65,FT70:FU83,GC70:GD83,GK70:GL83,GS70:GT82,GS83:GT83,HA70:HB83,HI70:HJ83,HQ70:HR83,FT88:FU101,GC88:GD101,GK88:GL101,GS88:GT101,HA88:HB101,HI88:HJ100,HI101:HJ101,HQ88:HR101,FT106:FU119" _
), Range( _
"CS47:CS65,EF47:EF65,BD67,CQ67,ED67,FQ67,Q70:R83,BF70:BF83,CS70:CS83,EF70:EF83,BD85,CQ85,ED85,FQ85,Q88:R101,BF88:BF101,CS88:CS101,EF88:EF101,BD103,CQ103,ED103,FQ103,Q106:R119,BF106:BF119,CS106:CS119,EF106:EF119,BD121,CQ121,ED121,FQ121" _
)).Select
Range("HQ106").Activate
Selection.ClearContents
Range("Q47").Select
ActiveWorkbook.Save
End Sub
Thanks for looking.
James
I don't know enough about VBA (hense why I recorded the macro rather than writing it) to trouble shoot it. I could use some help. The macro is tied to a button, and appears when I click the button. Here's the code, and the line that is highlighted when the error pops up: Compile error: Argument not optional
Sub Sheet_Clear()
'
' Sheet_Clear Macro
' Resets all data entry cells back to zero. Macro created by J. Streck on 10/21/2010.
'
Dim nResult As Long
nResult = MsgBox( _
Prompt:="Are you sure you want to clear your sheet? Click YES to clear, or NO to stop.", _
Buttons:=vbYesNo)
If nResult = vbNo Then
Exit Sub
End If
Range("Q47:R65,BF47:BF65,CS47:CS65,EF47:EF65,BD67,CQ67,ED67,FQ67").Select
Range("FQ67").Activate
Range( _
"Q47:R65,BF47:BF65,CS47:CS65,EF47:EF65,BD67,CQ67,ED67,FQ67,Q70:R83,BF70:BF83,CS70:CS83,EF70:EF83,BD85,CQ85,ED85,FQ85" _
).Select
Range("FQ85").Activate
Range( _
"Q47:R65,BF47:BF65,CS47:CS65,EF47:EF65,BD67,CQ67,ED67,FQ67,Q70:R83,BF70:BF83,CS70:CS83,EF70:EF83,BD85,CQ85,ED85,FQ85,Q88:R101,BF88:BF101,CS88:CS101,EF88:EF101,BD103,CQ103,ED103,FQ103" _
).Select
Range("FQ103").Activate
Union(Range( _
"Q47:R65,BF47:BF65,CS47:CS65,EF47:EF65,BD67,CQ67,ED67,FQ67,Q70:R83,BF70:BF83,CS70:CS83,EF70:EF83,BD85,CQ85,ED85,FQ85,Q88:R101,BF88:BF101,CS88:CS101,EF88:EF101,BD103,CQ103,ED103,FQ103,Q106:R119,BF106:BF119,CS106:CS119,EF106:EF119,BD121,CQ121,ED121,FQ121" _
)).Select
Range("FQ121").Activate
Union(Range( _
"FT47:FU65,GC47:GD65,GK47:GL65,GS47:GT65,HA47:HB65,HI47:HJ65,Q47:R65,BF47:BF65,CS47:CS65,EF47:EF65,BD67,CQ67,ED67,FQ67,Q70:R83,BF70:BF83,CS70:CS83,EF70:EF83,BD85,CQ85,ED85,FQ85,Q88:R101,BF88:BF101,CS88:CS101,EF88:EF101,BD103,CQ103,ED103,FQ103,Q106:R119" _
), Range("CS106:CS119,EF106:EF119,BD121,CQ121,ED121,FQ121")).Select
Range("HI47").Activate
Union(Range( _
"FT47:FU65,GC47:GD65,GK47:GL65,GS47:GT65,HA47:HB65,HI47:HJ65,HQ47:HR65,Q47:R65,BF47:BF65,CS47:CS65,EF47:EF65,BD67,CQ67,ED67,FQ67,Q70:R83,BF70:BF83,CS70:CS83,EF70:EF83,BD85,CQ85,ED85,FQ85,Q88:R101,BF88:BF101,CS88:CS101,EF88:EF101,BD103,CQ103,ED103,FQ103" _
), Range("BF106:BF119,CS106:CS119,EF106:EF119,BD121,CQ121,ED121,FQ121")).Select
Range("HQ47").Activate
Union(Range( _
"FT47:FU65,GC47:GD65,GK47:GL65,GS47:GT65,HA47:HB65,HI47:HJ65,HQ47:HR65,FT70:FU83,GC70:GD83,GK70:GL83,GS70:GT82,GS83:GT83,HA70:HB83,Q47:R65,BF47:BF65,CS47:CS65,EF47:EF65,BD67,CQ67,ED67,FQ67,Q70:R83,BF70:BF83,CS70:CS83,EF70:EF83,BD85,CQ85,ED85,FQ85,Q88:R101" _
), Range( _
"EF88:EF101,BD103,CQ103,ED103,FQ103,Q106:R119,BF106:BF119,CS106:CS119,EF106:EF119,BD121,CQ121,ED121,FQ121" _
)).Select
Range("HA70").Activate
Union(Range( _
"FT47:FU65,GC47:GD65,GK47:GL65,GS47:GT65,HA47:HB65,HI47:HJ65,HQ47:HR65,FT70:FU83,GC70:GD83,GK70:GL83,GS70:GT82,GS83:GT83,HA70:HB83,HI70:HJ83,HQ70:HR83,Q47:R65,BF47:BF65,CS47:CS65,EF47:EF65,BD67,CQ67,ED67,FQ67,Q70:R83,BF70:BF83,CS70:CS83,EF70:EF83,BD85,CQ85" _
), Range( _
"BF88:BF101,CS88:CS101,EF88:EF101,BD103,CQ103,ED103,FQ103,Q106:R119,BF106:BF119,CS106:CS119,EF106:EF119,BD121,CQ121,ED121,FQ121" _
)).Select
Range("HQ70").Activate
Union(Range( _
"FT47:FU65,GC47:GD65,GK47:GL65,GS47:GT65,HA47:HB65,HI47:HJ65,HQ47:HR65,FT70:FU83,GC70:GD83,GK70:GL83,GS70:GT82,GS83:GT83,HA70:HB83,HI70:HJ83,HQ70:HR83,FT88:FU101,GC88:GD101,GK88:GL101,GS88:GT101,HA88:HB101,Q47:R65,BF47:BF65,CS47:CS65,EF47:EF65,BD67,CQ67,ED67" _
), Range( _
"BD85,CQ85,ED85,FQ85,Q88:R101,BF88:BF101,CS88:CS101,EF88:EF101,BD103,CQ103,ED103,FQ103,Q106:R119,BF106:BF119,CS106:CS119,EF106:EF119,BD121,CQ121,ED121,FQ121" _
)).Select
Range("HA88").Activate
Union(Range( _
"FT47:FU65,GC47:GD65,GK47:GL65,GS47:GT65,HA47:HB65,HI47:HJ65,HQ47:HR65,FT70:FU83,GC70:GD83,GK70:GL83,GS70:GT82,GS83:GT83,HA70:HB83,HI70:HJ83,HQ70:HR83,FT88:FU101,GC88:GD101,GK88:GL101,GS88:GT101,HA88:HB101,HI88:HJ100,HI101:HJ101,HQ88:HR101,Q47:R65,BF47:BF65" _
), Range( _
"BF70:BF83,CS70:CS83,EF70:EF83,BD85,CQ85,ED85,FQ85,Q88:R101,BF88:BF101,CS88:CS101,EF88:EF101,BD103,CQ103,ED103,FQ103,Q106:R119,BF106:BF119,CS106:CS119,EF106:EF119,BD121,CQ121,ED121,FQ121" _
)).Select
Range("HQ88").Activate
Union(Range( _
"FT47:FU65,GC47:GD65,GK47:GL65,GS47:GT65,HA47:HB65,HI47:HJ65,HQ47:HR65,FT70:FU83,GC70:GD83,GK70:GL83,GS70:GT82,GS83:GT83,HA70:HB83,HI70:HJ83,HQ70:HR83,FT88:FU101,GC88:GD101,GK88:GL101,GS88:GT101,HA88:HB101,HI88:HJ100,HI101:HJ101,HQ88:HR101,FT106:FU119" _
), Range( _
"ED67,FQ67,Q70:R83,BF70:BF83,CS70:CS83,EF70:EF83,BD85,CQ85,ED85,FQ85,Q88:R101,BF88:BF101,CS88:CS101,EF88:EF101,BD103,CQ103,ED103,FQ103,Q106:R119,BF106:BF119,CS106:CS119,EF106:EF119,BD121,CQ121,ED121,FQ121" _
)).Select
Range("GK106").Activate
Union(Range( _
"FT47:FU65,GC47:GD65,GK47:GL65,GS47:GT65,HA47:HB65,HI47:HJ65,HQ47:HR65,FT70:FU83,GC70:GD83,GK70:GL83,GS70:GT82,GS83:GT83,HA70:HB83,HI70:HJ83,HQ70:HR83,FT88:FU101,GC88:GD101,GK88:GL101,GS88:GT101,HA88:HB101,HI88:HJ100,HI101:HJ101,HQ88:HR101,FT106:FU119" _
), Range( _
"CS47:CS65,EF47:EF65,BD67,CQ67,ED67,FQ67,Q70:R83,BF70:BF83,CS70:CS83,EF70:EF83,BD85,CQ85,ED85,FQ85,Q88:R101,BF88:BF101,CS88:CS101,EF88:EF101,BD103,CQ103,ED103,FQ103,Q106:R119,BF106:BF119,CS106:CS119,EF106:EF119,BD121,CQ121,ED121,FQ121" _
)).Select
Range("HQ106").Activate
Selection.ClearContents
Range("Q47").Select
ActiveWorkbook.Save
End Sub
Thanks for looking.
James