Dynamically assign macro

  • Thread starter Thread starter John Smith
  • Start date Start date
Hi again
Select that checkbox and in the name box above cell A1 give it a name.I called
it "stock" in the macro. You need to change it to your choice.
This way it will be unique. then this will delete all but that one.

Sub saveonebox()
Dim myCBX As CheckBox
    For Each myCBX In ActiveSheet.CheckBoxes
       If Not myCBX.Name = "stock" Then
        myCBX.Delete
        End If
    Next myCBX
End Sub






How would I protect that single cell, since I need to delete
everything else on the page every time it gets used?- Hide quoted text -

- Show quoted text -

I can't seem to get it to work - it still deletes the checkbox in A1.
 
This is a link to a sample file that you can play with.
http://cjoint.com/?BAsd5Lr4hYe
Cimjet
Hi again
Select that checkbox and in the name box above cell A1 give it a name.I called
it "stock" in the macro. You need to change it to your choice.
This way it will be unique. then this will delete all but that one.

Sub saveonebox()
Dim myCBX As CheckBox
For Each myCBX In ActiveSheet.CheckBoxes
If Not myCBX.Name = "stock" Then
myCBX.Delete
End If
Next myCBX
End Sub






How would I protect that single cell, since I need to delete
everything else on the page every time it gets used?- Hide quoted text -

- Show quoted text -

I can't seem to get it to work - it still deletes the checkbox in A1.
 
Hi again
Select that checkbox and in the name box above cell A1 give it a name.I called
it "stock" in the macro. You need to change it to your choice.
This way it will be unique. then this will delete all but that one.

Sub saveonebox()
Dim myCBX As CheckBox
    For Each myCBX In ActiveSheet.CheckBoxes
       If Not myCBX.Name = "stock" Then
        myCBX.Delete
        End If
    Next myCBX
End Sub






How would I protect that single cell, since I need to delete
everything else on the page every time it gets used?- Hide quoted text -

- Show quoted text -

Eureka! I got it. Thanks Cimjet.
 
Great, glad you got it working
Good night
Cimjet
Hi again
Select that checkbox and in the name box above cell A1 give it a name.I called
it "stock" in the macro. You need to change it to your choice.
This way it will be unique. then this will delete all but that one.

Sub saveonebox()
Dim myCBX As CheckBox
For Each myCBX In ActiveSheet.CheckBoxes
If Not myCBX.Name = "stock" Then
myCBX.Delete
End If
Next myCBX
End Sub






How would I protect that single cell, since I need to delete
everything else on the page every time it gets used?- Hide quoted text -

- Show quoted text -

Eureka! I got it. Thanks Cimjet.
 
Back
Top