I’m using the following script to produce buttons in excel, the range is just where I’d like it to be placed.
Sub CreateAddButton(rng As Range)
Dim btn As Button
With Worksheets("User")
Set btn = .Buttons.Add(rng.Left, rng.Top, rng.width, rng.Height)
With btn
.name = "Add"
.Caption = "Add Column"
.OnAction = "CreateVariable"
End With
End With
End Sub
Only problem is, I’d like a method which can delete all the buttons produced by this method? I want to steer away from global variables if possible. Any help would be gratefully received.
James
I’d suggest Tim’s method using a specific name – which does’t need a global variable. For example you could add a
“_||ForDeletion” suffix to each button name and then look for it on a delete routine
A
Formsbutton does provide another alternative though (no pun intended), you can store a text sting in theAlternativeTextunder “Properties” then “Web” and use this as an identifier for a delete routine.The delete routine at bottom works backwards to avoid errors when looping through a range