ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   looping through userform controls changing enabled and locked properties (https://www.excelbanter.com/excel-programming/306966-looping-through-userform-controls-changing-enabled-locked-properties.html)

JulieD

looping through userform controls changing enabled and locked properties
 
Hi All

i'm trying to (Excel 2000) loop through userform controls which are set to
enabled = false & locked = true to change them to enabled = true and locked
= false on the On Click of a command button.

I have John Walkenbach's book (excel 2002) where he shows code for looping
through controls but i can't seem to find a way to get to either the enabled
or locked properties - everything i tried resulted in excel crashing !

Help!

Thanks
JulieD




Nigel

looping through userform controls changing enabled and locked properties
 
This will switch the state of the control as you required, incorporate this
into your control loop to act on each control.

Private Sub CommandButton1_Click()
With TextBox1
If .Enabled Then
.Enabled = False
.Locked = True
Else
.Enabled = True
.Locked = False
End If
End With
End Sub

Cheers
Nigel

"JulieD" wrote in message
...
Hi All

i'm trying to (Excel 2000) loop through userform controls which are set to
enabled = false & locked = true to change them to enabled = true and

locked
= false on the On Click of a command button.

I have John Walkenbach's book (excel 2002) where he shows code for looping
through controls but i can't seem to find a way to get to either the

enabled
or locked properties - everything i tried resulted in excel crashing !

Help!

Thanks
JulieD






Bob Phillips[_6_]

looping through userform controls changing enabled and locked properties
 
Julie,

Here is an example

Dim ctl As msforms.Control

For Each ctl In Me.Controls
If TypeName(ctl) = "TextBox" Then
If ctl.Enabled Then
MsgBox ctl.Name
End If
End If
Next ctl

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"JulieD" wrote in message
...
Hi All

i'm trying to (Excel 2000) loop through userform controls which are set to
enabled = false & locked = true to change them to enabled = true and

locked
= false on the On Click of a command button.

I have John Walkenbach's book (excel 2002) where he shows code for looping
through controls but i can't seem to find a way to get to either the

enabled
or locked properties - everything i tried resulted in excel crashing !

Help!

Thanks
JulieD







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

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