Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have somehow got thousnads of option buttons in my Excel worksheet. I would
like to write a simple code that would remove them using a macro instead of manually deleting them. The option buttons are not in continuos numbers so the code needs to check if the button exists first and then delete. I am a novice and cannot write the above code. Thanks |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This code assumes you got your buttons from the Forms Toolbar...
Sub RemoveButtons() Dim btn As Button For Each btn In Buttons btn.Delete Next btn End Sub -- HTH... Jim Thomlinson "RitaJ" wrote: I have somehow got thousnads of option buttons in my Excel worksheet. I would like to write a simple code that would remove them using a macro instead of manually deleting them. The option buttons are not in continuos numbers so the code needs to check if the button exists first and then delete. I am a novice and cannot write the above code. Thanks |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
If they are option buttons from the Control toolbox, then try something like this: Sub test() Dim o As OLEObject For Each o In ActiveSheet.OLEObjects If TypeName(o.Object) = "OptionButton" Then o.Delete End If Next o End Sub If they are option buttons from the Forms toolbox, then something like this: Sub test2() Dim b As OptionButton For Each b In ActiveSheet.OptionButtons b.Delete Next b End Sub -- Hope that helps. Vergel Adriano "RitaJ" wrote: I have somehow got thousnads of option buttons in my Excel worksheet. I would like to write a simple code that would remove them using a macro instead of manually deleting them. The option buttons are not in continuos numbers so the code needs to check if the button exists first and then delete. I am a novice and cannot write the above code. Thanks |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Oops you wanted option buttons... Try this...
Sub RemoveButtons() Dim btn As OptionButton For Each btn In OptionButtons btn.Delete Next btn End Sub -- HTH... Jim Thomlinson "Jim Thomlinson" wrote: This code assumes you got your buttons from the Forms Toolbar... Sub RemoveButtons() Dim btn As Button For Each btn In Buttons btn.Delete Next btn End Sub -- HTH... Jim Thomlinson "RitaJ" wrote: I have somehow got thousnads of option buttons in my Excel worksheet. I would like to write a simple code that would remove them using a macro instead of manually deleting them. The option buttons are not in continuos numbers so the code needs to check if the button exists first and then delete. I am a novice and cannot write the above code. Thanks |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The code stopped in line "For Each btn in Buttons"
RJ "Jim Thomlinson" wrote: This code assumes you got your buttons from the Forms Toolbar... Sub RemoveButtons() Dim btn As Button For Each btn In Buttons btn.Delete Next btn End Sub -- HTH... Jim Thomlinson "RitaJ" wrote: I have somehow got thousnads of option buttons in my Excel worksheet. I would like to write a simple code that would remove them using a macro instead of manually deleting them. The option buttons are not in continuos numbers so the code needs to check if the button exists first and then delete. I am a novice and cannot write the above code. Thanks |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Many Thanks.
Test 2 worked perfect. RJ "Vergel Adriano" wrote: Hi, If they are option buttons from the Control toolbox, then try something like this: Sub test() Dim o As OLEObject For Each o In ActiveSheet.OLEObjects If TypeName(o.Object) = "OptionButton" Then o.Delete End If Next o End Sub If they are option buttons from the Forms toolbox, then something like this: Sub test2() Dim b As OptionButton For Each b In ActiveSheet.OptionButtons b.Delete Next b End Sub -- Hope that helps. Vergel Adriano "RitaJ" wrote: I have somehow got thousnads of option buttons in my Excel worksheet. I would like to write a simple code that would remove them using a macro instead of manually deleting them. The option buttons are not in continuos numbers so the code needs to check if the button exists first and then delete. I am a novice and cannot write the above code. Thanks |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If there aren't too many:
ActiveSheet.OptionButtons.delete should work, too. RitaJ wrote: Many Thanks. Test 2 worked perfect. RJ "Vergel Adriano" wrote: Hi, If they are option buttons from the Control toolbox, then try something like this: Sub test() Dim o As OLEObject For Each o In ActiveSheet.OLEObjects If TypeName(o.Object) = "OptionButton" Then o.Delete End If Next o End Sub If they are option buttons from the Forms toolbox, then something like this: Sub test2() Dim b As OptionButton For Each b In ActiveSheet.OptionButtons b.Delete Next b End Sub -- Hope that helps. Vergel Adriano "RitaJ" wrote: I have somehow got thousnads of option buttons in my Excel worksheet. I would like to write a simple code that would remove them using a macro instead of manually deleting them. The option buttons are not in continuos numbers so the code needs to check if the button exists first and then delete. I am a novice and cannot write the above code. Thanks -- Dave Peterson |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Dave. I didn't know you could do that.
-- HTH... Jim Thomlinson "Dave Peterson" wrote: If there aren't too many: ActiveSheet.OptionButtons.delete should work, too. RitaJ wrote: Many Thanks. Test 2 worked perfect. RJ "Vergel Adriano" wrote: Hi, If they are option buttons from the Control toolbox, then try something like this: Sub test() Dim o As OLEObject For Each o In ActiveSheet.OLEObjects If TypeName(o.Object) = "OptionButton" Then o.Delete End If Next o End Sub If they are option buttons from the Forms toolbox, then something like this: Sub test2() Dim b As OptionButton For Each b In ActiveSheet.OptionButtons b.Delete Next b End Sub -- Hope that helps. Vergel Adriano "RitaJ" wrote: I have somehow got thousnads of option buttons in my Excel worksheet. I would like to write a simple code that would remove them using a macro instead of manually deleting them. The option buttons are not in continuos numbers so the code needs to check if the button exists first and then delete. I am a novice and cannot write the above code. Thanks -- Dave Peterson |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The bad news is that it fails when that number of shapes gets large. But if you
know your worksheet (or can live with the error), then it's a nice way to start. Jim Thomlinson wrote: Thanks Dave. I didn't know you could do that. -- HTH... Jim Thomlinson "Dave Peterson" wrote: If there aren't too many: ActiveSheet.OptionButtons.delete should work, too. RitaJ wrote: Many Thanks. Test 2 worked perfect. RJ "Vergel Adriano" wrote: Hi, If they are option buttons from the Control toolbox, then try something like this: Sub test() Dim o As OLEObject For Each o In ActiveSheet.OLEObjects If TypeName(o.Object) = "OptionButton" Then o.Delete End If Next o End Sub If they are option buttons from the Forms toolbox, then something like this: Sub test2() Dim b As OptionButton For Each b In ActiveSheet.OptionButtons b.Delete Next b End Sub -- Hope that helps. Vergel Adriano "RitaJ" wrote: I have somehow got thousnads of option buttons in my Excel worksheet. I would like to write a simple code that would remove them using a macro instead of manually deleting them. The option buttons are not in continuos numbers so the code needs to check if the button exists first and then delete. I am a novice and cannot write the above code. Thanks -- Dave Peterson -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
I need a visual basic code....please | Excel Discussion (Misc queries) | |||
Visual Basic Code | Excel Programming | |||
VISUAL BASIC CODE | Excel Programming | |||
visual basic code | Excel Programming | |||
Visual Basic Code | Excel Programming |