I've got a bit of code that creates a Save button on a worksheet (held in the wsReport
variable), but it doesn't remove previous buttons. Over time, they tend to build up. Is there any way to do something like this?
wsReport.Buttons.All.Delete
(Not right, obviously, but gives an idea of what I'm looking for.)
See code below :)
Sub RemoveButtons()
Dim i As Integer
If ActiveSheet.ProtectContents = True Then
MsgBox "The Current Workbook or the Worksheets which it contains are protected." & vbLf & " Please resolve these issues and try again."
End If
On Error Resume Next
ActiveSheet.Buttons.Delete
End Sub
Source: http://www.mrexcel.com/forum/excel-questions/609668-delete-all-buttons-sheet-visual-basic-applications.html
or could you use code below: (Buttons in VBA are in the Shapes collection).
Sub DelButtons()
Dim btn As Shape
For Each btn In ActiveSheet.Shapes
If btn.AutoShapeType = msoShapeStyleMixed Then btn.Delete
Next
End Sub
source: Deleting a collections of VBA buttons
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With