ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   selection all textboxes in userform at once (https://www.excelbanter.com/excel-programming/323564-selection-all-textboxes-userform-once.html)

Marthijn Beusekom via OfficeKB.com

selection all textboxes in userform at once
 
I made a userform with over 20 textboxes (TBX). All boxes have a 'easy to
understand' name. At some moment I need all testboxes to be 'opened' or
'blocked' or to be 'emptied'. Is there a way to select all TBX at once?

My current solution looks like this:

MultiPage1.Value = 0 'Gegevens
GegKl.Enabled = True
GegNm.Enabled = True
GegRubr1.Enabled = True
GegRubr2.Enabled = True
GegStnr.Enabled = True
GegWplts.Enabled = True
MultiPage1.Value = 1 'Dressuur
DrPnt.Enabled = True
DrPntOv.Enabled = True
DrStnr.Enabled = True

Thank you so much for your help!!

--
Message posted via http://www.officekb.com

Claud Balls

selection all textboxes in userform at once
 
I don't think that you can select one type of controls, and change there
values at the same time. You can loop through your controls. I've
posted some code I've used to clear all my text boxes.

For Each txtcontrol In Controls
If Left(txtcontrol.Name, 2) = "tx" Then txtcontrol.Text = ""
Next

As a naming standard, all of my text boxes start with "tx" so that is
how I clear only text boxes.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Tushar Mehta

selection all textboxes in userform at once
 
In addition to Claud's suggestion, you can also check the type of each
control. Something along the lines of

Dim x As MSForms.Control
For Each x In Me.Controls
If TypeOf x Is MSForms.TextBox Then
x.Enabled = Not x.Enabled
End If
Next x

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
I made a userform with over 20 textboxes (TBX). All boxes have a 'easy to
understand' name. At some moment I need all testboxes to be 'opened' or
'blocked' or to be 'emptied'. Is there a way to select all TBX at once?

My current solution looks like this:

MultiPage1.Value = 0 'Gegevens
GegKl.Enabled = True
GegNm.Enabled = True
GegRubr1.Enabled = True
GegRubr2.Enabled = True
GegStnr.Enabled = True
GegWplts.Enabled = True
MultiPage1.Value = 1 'Dressuur
DrPnt.Enabled = True
DrPntOv.Enabled = True
DrStnr.Enabled = True

Thank you so much for your help!!




All times are GMT +1. The time now is 02:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com