Code to clear data validation in selected cell and sheet, assigned to button

Ironman

Well-known Member
Joined
Jan 31, 2004
Messages
1,069
Office Version
  1. 365
Platform
  1. Windows
Hello

I'd like to be able to clear all data validation (including validation comments) from a single selected cell

- only in a sheet called Training Log and

- only when I click on an assigned button, preceded by a "Are you sure?" Yes/Cancel msgbox.

I tried the following code for the deletion part, which doesn't work
Code:
SubClearValidation()
      If ActiveSheet.Name = "Training Log" Then
        With Selection.Validation
          .Delete
          End If
          End With
          End Sub

Hope you can help?

Many thanks.
 
Last edited:

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
You have the End With & End if the wrong way round
 
Upvote 0
Many thanks Fluff.

Could you please help me with the msgbox?

Thanks again!
 
Upvote 0
How about
Code:
Sub ClearValidation()
   If ActiveSheet.Name = "Training Log" Then
      If MsgBox("Are you sure", vbYesNo) = vbYes Then
         Selection.Validation.Delete
      End If
   End If
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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