DVA Clear Botn Debug Error

spacedad41

New Member
Joined
May 18, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
I have copy and clear button on my excel page however my clear is giving me a debug message. Posting code below

Sub Copy8hr()
'
' Copy8hr Macro
'

'
Range("A1:j46").Select
Selection.Copy
End Sub
Sub Clear8hrButyric()
'
' Clear8hrButyric Macro
'

'
Range("B3:c6").Select
Selection.ClearContents
Range("e1:e3").Select
Selection.ClearContents
Range("B9").Select
Selection.ClearContents
Range("B12").Select
Selection.ClearContents
Range("B15").Select
Selection.ClearContents
Range("b18").Select
Selection.ClearContents
Range("b21").Select
Selection.ClearContents
Range("B24").Select
Selection.ClearContents
Range("b27").Select
Selection.ClearContents
Range("b30").Select
Selection.ClearContents
Range("B33").Select
Selection.ClearContents
Range("b36").Select
Selection.ClearContents
Range("f4:j7").Select
Selection.ClearContents
Range("a42:j46").Select
Selection.ClearContents
ActiveWindow.SmallScroll Down:=9
Range("A27").Select
ActiveWindow.SmallScroll Down:=-12
End Sub
Sub Copy4hrButyric()
'
' Copy4hrButyric Macro
'

'
Range("A1:I38").Select
Selection.Copy
End Sub
Sub Clear4hr()
'
' Clear4hr Macro
'

'
Range("B3:d6").Select
Selection.ClearContents
Range("B9").Select
Selection.ClearContents
Range("B15").Select
Selection.ClearContents
Range("B18:b19").Select
Selection.ClearContents
Range("A24:A27").Select
Selection.ClearContents
Range("A30:C38").Select
Selection.ClearContents
Range("A24").Select
ActiveWindow.SmallScroll Down:=-12
End Sub
Sub CopyHB()
'
' CopyHB Macro
'

'
Range("A1:j19").Select
Selection.Copy
End Sub
Sub ClearHB()
'
' ClearHB Macro
'

'
Range("B3:c6").Select
Selection.ClearContents
Range("B9").Select
Selection.ClearContents
Range("B11").Select
Selection.ClearContents
Range("B12").Select
Selection.ClearContents
Range("A17:C19").Select
Selection.ClearContents
Range("B3").Select

End Sub
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Which message do you receive and on which line? Is the "active" worksheet protected?
Please use "tags", they improve the readability of your code.

It will not fix the error, but note that you can replace all those Range(Xx:Yy).Select /Selection.ClearContents with a neater
VBA Code:
Range("Xx:Yy").ClearContents
 
Upvote 0

Forum statistics

Threads
1,214,965
Messages
6,122,496
Members
449,089
Latest member
Raviguru

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top