Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Clear Textboxes, Labels, and Checkboxes

I have a worksheet contains about 100 textboxes, labels,
and checkboxes. I would like to clear all the text from
these text boxes and labels, and uncheck all checkboxes at
once. Is there a way to set these textboxes, labels, and
checkboxes in an array and then using a loop to clear all
the text and uncheck the checkboxes instead of writing a
code for each of them (textbox1.text = "")?

Thanks,
milo
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default Clear Textboxes, Labels, and Checkboxes

Milo,

Here's a modified version of a macro that was given to me.

Sub ClearMyObjects()
Dim oleObj As OLEObject
For Each oleObj In ActiveSheet.OLEObjects
If TypeOf oleObj.Object Is MSForms.Textbox Then
oleobj.Object.Text = ""
ElseIf TypeOf oleObj.Object Is MSForms.Checkbox Then
oleobj.Object.Value = False
End If
Next
End Sub

Note that my objects were from the Controls Toolbox.
It won't work for objects from the Forms Toolbar.
Tested this in Excel97 SR2 and it works.
Even works on a sheet that doesn't have any objects.
--
sb
"milo" wrote in message
...
I have a worksheet contains about 100 textboxes, labels,
and checkboxes. I would like to clear all the text from
these text boxes and labels, and uncheck all checkboxes at
once. Is there a way to set these textboxes, labels, and
checkboxes in an array and then using a loop to clear all
the text and uncheck the checkboxes instead of writing a
code for each of them (textbox1.text = "")?

Thanks,
milo



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Clear certain checkboxes Arlen Excel Discussion (Misc queries) 4 May 20th 10 11:42 PM
How to clear all checkboxes on a form? Arlen Excel Worksheet Functions 2 May 6th 10 04:20 PM
Macro to clear checkboxes Guy[_2_] Excel Worksheet Functions 5 January 2nd 09 08:39 PM
Clear Checkboxes fak119 Excel Discussion (Misc queries) 1 March 22nd 07 04:43 PM
Clear Comboboxes & Textboxes MBlake New Users to Excel 3 May 2nd 05 10:29 PM


All times are GMT +1. The time now is 07:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"