PC Review


Reply
Thread Tools Rate Thread

Clear Textboxes, Labels, and Checkboxes

 
 
milo
Guest
Posts: n/a
 
      16th Oct 2003
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 With Quote
 
 
 
 
steve
Guest
Posts: n/a
 
      16th Oct 2003
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" <(E-Mail Removed)> wrote in message
news:036901c39419$44537800$(E-Mail Removed)...
> 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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel UserForm textboxes and checkboxes??? TotallyConfused Microsoft Excel Programming 3 15th Sep 2009 06:28 AM
Clear Form's textboxes and checkboxes??? TotallyConfused Microsoft Access VBA Modules 1 15th Sep 2009 01:10 AM
RE: Textboxes, checkboxes, option groups.... KARL DEWEY Microsoft Access Getting Started 0 7th May 2008 07:44 PM
How do I insert controls such as textboxes and checkboxes? =?Utf-8?B?dnZlbms=?= Microsoft Word Document Management 0 3rd May 2007 09:03 PM
Re: Using checkboxes and textboxes to create a document. Doug Robbins Microsoft Word Document Management 0 5th Jul 2004 02:04 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:38 PM.