ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Delete Data Button (https://www.excelbanter.com/excel-discussion-misc-queries/85726-delete-data-button.html)

Marcus

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

[email protected]

Delete Data Button
 
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


Marcus

Delete Data Button
 
So do I need to create a command button?

" wrote:

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



[email protected]

Delete Data Button
 
Go to TOOLSMACROVisual 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:)



All times are GMT +1. The time now is 02:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com