Delete Data Button

M

Marcus

I am trying to create a button that when you click it it will delete all data
in a workbook. Anyone have any ideas???
 
A

arthurjr07

Private Sub CommandButton1_Click()
Dim ws As Worksheet
Dim r As Range
For Each ws In Worksheets
ws.Activate
For Each r In ws.UsedRange
MsgBox r
Next r
Next
End Sub
 
A

arthurjr07

Go to TOOLS>MACRO>Visual Basic Editor

then Right Click on VBAProjects on the project window then Insert >
UserForm

On the user form, insert a commandbutton
copy and paste the code and then run

I hope u understand what i am trying to say:)
 
Top