Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default Using a checkbox to activate/deactivate input option

I have created a program using VBA and I am attempting to use a form
for my first time. I want to have a checkbox that when checked allows
users to input additional items into the form. by default I want the
box to be unchecked and those input boxes grayed out and disabled.
what is the best way to do this? thanks.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 644
Default Using a checkbox to activate/deactivate input option

In the userform code area, use the userform_initialize sub with code
like this:
CheckBox1.Value = False
In the CheckBox1_Change Event use code like this:
TextBox1.Enabled = Not(CheckBox1.Value)
TextBox3.Enabled = Not(CheckBox1.Value)

HTH

Charles

Jacob wrote:
I have created a program using VBA and I am attempting to use a form
for my first time. I want to have a checkbox that when checked allows
users to input additional items into the form. by default I want the
box to be unchecked and those input boxes grayed out and disabled.
what is the best way to do this? thanks.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Using a checkbox to activate/deactivate input option

add code like this to the form

Private Sub CheckBox1_Click()
With Me
If .CheckBox1.Value = True Then
.TextBox1.Enabled = True
.TextBox1.BackColor = &HFFFFFF
.TextBox1.Enabled = True
.TextBox2.BackColor = &HFFFFFF
End If
End With
End Sub

Private Sub UserForm_Initialize()
With Me
.CheckBox1.Value = False
.TextBox1.Enabled = False
.TextBox1.BackColor = &HC0C0C0
.TextBox2.Enabled = False
.TextBox2.BackColor = &HC0C0C0
End With
End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Jacob" wrote in message
oups.com...
I have created a program using VBA and I am attempting to use a form
for my first time. I want to have a checkbox that when checked allows
users to input additional items into the form. by default I want the
box to be unchecked and those input boxes grayed out and disabled.
what is the best way to do this? thanks.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default Using a checkbox to activate/deactivate input option

Thanks for the help. Chalres, I could not get yours to work. Bob, I
added an "else" to get the cells to revert to the default of gray and
disabled after being checked and unchecked. other than that, it
appears to be working perfectly.

thanks!


Private Sub CheckBoxShearEnv_Click()
With Me
If .CheckBoxShearEnv.Value = True Then
.TextBoxIncrement.Enabled = True
.TextBoxIncrement.BackColor = &HFFFFFF
.TextBoxStepSize.Enabled = True
.TextBoxStepSize.BackColor = &HFFFFFF

Else
.CheckBoxShearEnv.Value = False
.TextBoxIncrement.Enabled = False
.TextBoxIncrement.BackColor = &HC0C0C0
.TextBoxStepSize.Enabled = False
.TextBoxStepSize.BackColor = &HC0C0C0

End If
End With
End Sub

Private Sub UserForm1_Initialize()
With Me
.CheckBoxShearEnv.Value = False
.TextBoxIncrement.Enabled = False
.TextBoxIncrement.BackColor = &HC0C0C0
.TextBoxStepSize.Enabled = False
.TextBoxStepSize.BackColor = &HC0C0C0
End With
End Sub




Bob Phillips wrote:
add code like this to the form

Private Sub CheckBox1_Click()
With Me
If .CheckBox1.Value = True Then
.TextBox1.Enabled = True
.TextBox1.BackColor = &HFFFFFF
.TextBox1.Enabled = True
.TextBox2.BackColor = &HFFFFFF
End If
End With
End Sub

Private Sub UserForm_Initialize()
With Me
.CheckBox1.Value = False
.TextBox1.Enabled = False
.TextBox1.BackColor = &HC0C0C0
.TextBox2.Enabled = False
.TextBox2.BackColor = &HC0C0C0
End With
End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Jacob" wrote in message
oups.com...
I have created a program using VBA and I am attempting to use a form
for my first time. I want to have a checkbox that when checked allows
users to input additional items into the form. by default I want the
box to be unchecked and those input boxes grayed out and disabled.
what is the best way to do this? thanks.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Using a checkbox to activate/deactivate input option

I wondered if you would want them to revert <g

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Jacob" wrote in message
oups.com...
Thanks for the help. Chalres, I could not get yours to work. Bob, I
added an "else" to get the cells to revert to the default of gray and
disabled after being checked and unchecked. other than that, it
appears to be working perfectly.

thanks!


Private Sub CheckBoxShearEnv_Click()
With Me
If .CheckBoxShearEnv.Value = True Then
.TextBoxIncrement.Enabled = True
.TextBoxIncrement.BackColor = &HFFFFFF
.TextBoxStepSize.Enabled = True
.TextBoxStepSize.BackColor = &HFFFFFF

Else
.CheckBoxShearEnv.Value = False
.TextBoxIncrement.Enabled = False
.TextBoxIncrement.BackColor = &HC0C0C0
.TextBoxStepSize.Enabled = False
.TextBoxStepSize.BackColor = &HC0C0C0

End If
End With
End Sub

Private Sub UserForm1_Initialize()
With Me
.CheckBoxShearEnv.Value = False
.TextBoxIncrement.Enabled = False
.TextBoxIncrement.BackColor = &HC0C0C0
.TextBoxStepSize.Enabled = False
.TextBoxStepSize.BackColor = &HC0C0C0
End With
End Sub




Bob Phillips wrote:
add code like this to the form

Private Sub CheckBox1_Click()
With Me
If .CheckBox1.Value = True Then
.TextBox1.Enabled = True
.TextBox1.BackColor = &HFFFFFF
.TextBox1.Enabled = True
.TextBox2.BackColor = &HFFFFFF
End If
End With
End Sub

Private Sub UserForm_Initialize()
With Me
.CheckBox1.Value = False
.TextBox1.Enabled = False
.TextBox1.BackColor = &HC0C0C0
.TextBox2.Enabled = False
.TextBox2.BackColor = &HC0C0C0
End With
End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Jacob" wrote in message
oups.com...
I have created a program using VBA and I am attempting to use a form
for my first time. I want to have a checkbox that when checked allows
users to input additional items into the form. by default I want the
box to be unchecked and those input boxes grayed out and disabled.
what is the best way to do this? thanks.




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
activate/deactivate macro depending on who's the user anna Excel Discussion (Misc queries) 3 January 24th 10 11:11 PM
Links is in gray color (deactivate). How can I activate? Rechie Excel Discussion (Misc queries) 6 December 13th 09 11:10 AM
Activate/deactivate Office Clipboard in VBA Peter Rooney Excel Programming 0 December 6th 05 02:05 PM
activate/deactivate button with macro at given condition arcq Excel Programming 1 March 17th 05 05:35 AM
Activate / Deactivate mouse move event Rolo[_3_] Excel Programming 2 January 29th 04 01:50 PM


All times are GMT +1. The time now is 12:29 AM.

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

About Us

"It's about Microsoft Excel"