PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 1.00 average.

Delete Data from textboxes

 
 
nir020
Guest
Posts: n/a
 
      26th Nov 2007
Hello

I have created, using Excel VBA a userform allows users to write data into a
spefic spreadsheet. However, the form consists of about 30 textboxes. What I
would like the form to do is clear all the data from the textboxes once the
data has been submitted. Currently the form leaves whatever was last in the
textbox.

Is there any way this could be down using a for each command.

Thanks
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      26th Nov 2007
If you name the textboxes nicely (textbox1, textbox2, ..., textbox30), you could
use code like:

dim iCtr as long
for ictr = 1 to 30
me.controls("textbox" & ictr).value = ""
next ictr

If you didn't name them nicely, but they're the only textboxes on that userform:

dim ctrl as Control
for each ctrl in me.controls
if typeof ctrl is msforms.textbox then
ctrl.value = ""
end if
next ctrl


nir020 wrote:
>
> Hello
>
> I have created, using Excel VBA a userform allows users to write data into a
> spefic spreadsheet. However, the form consists of about 30 textboxes. What I
> would like the form to do is clear all the data from the textboxes once the
> data has been submitted. Currently the form leaves whatever was last in the
> textbox.
>
> Is there any way this could be down using a for each command.
>
> Thanks


--

Dave Peterson
 
Reply With Quote
 
Joel
Guest
Posts: n/a
 
      26th Nov 2007

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 11/26/2007 by Joel
'

'
For Each shp In ActiveSheet.Shapes
If shp.Type = msoTextBox Then

shp.DrawingObject.Caption = ""
End If
Next shp

End Sub

"nir020" wrote:

> Hello
>
> I have created, using Excel VBA a userform allows users to write data into a
> spefic spreadsheet. However, the form consists of about 30 textboxes. What I
> would like the form to do is clear all the data from the textboxes once the
> data has been submitted. Currently the form leaves whatever was last in the
> textbox.
>
> Is there any way this could be down using a for each command.
>
> Thanks

 
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
Delete some textboxes with tag,VBA Edward Microsoft Powerpoint 1 19th Nov 2008 07:20 PM
Show Results in TextBoxes, ONLY if All TextBoxes have Data in them =?Utf-8?B?Unlhbkg=?= Microsoft Excel Programming 3 19th Nov 2007 03:30 PM
Delete text in bound textboxes ? SpookiePower Microsoft Access Forms 3 3rd May 2007 05:46 PM
Textboxes - restrict double-click and selection.delete korrin.anderson@gmail.com Microsoft Excel Programming 0 18th May 2006 09:07 PM
How to Delete a child row using textboxes and datarelations Charles Microsoft ADO .NET 0 29th Sep 2003 05:40 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:22 PM.