• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

command button coding for clearing content of specific cells

Martin Lloyd

New Member
I would like to set up a command button in VBA that, when activated, clears the contents of specified cells in a worksheet (with a caution 'are you sure?')
Could you let me know the coding for this, please?
Thanks
 
Code:
Sub Clear_Me()
  Dim ans As Integer
  ans = MsgBox("Are you sure", vbOKCancel, "Clear my area")
  If ans = 1 Then Range("B3:E10,F11:I18,J19:K22").ClearContents 'Change range to suit yourself
End Sub
 
Back
Top