Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Show checkbox checked on open

I need help.

I have 3 userforms. Userform1 has 2 buttons, one to start a new project and
one that edits the project as saved. Which ever button is clicked brings up
userform2 which has 5 checkboxes.

What I would like to happen: when the edit button is clicked I would like
the checkboxes that were checked the last time to show up as checked. The
value of the checkboxes are stored on sheet3 in cells c2-c6.

Thank you for your time and assistance.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Show checkbox checked on open

You could probably set up a linked cell (control source) for each checkbox
which would hold the value of the checkbox until the form is reopened and
will show that value upon open.
"Solution4U" wrote:

I need help.

I have 3 userforms. Userform1 has 2 buttons, one to start a new project and
one that edits the project as saved. Which ever button is clicked brings up
userform2 which has 5 checkboxes.

What I would like to happen: when the edit button is clicked I would like
the checkboxes that were checked the last time to show up as checked. The
value of the checkboxes are stored on sheet3 in cells c2-c6.

Thank you for your time and assistance.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Show checkbox checked on open

Could you show me an example of code for that? I am rather new to vba.

Thank you for the response.

"JLGWhiz" wrote:

You could probably set up a linked cell (control source) for each checkbox
which would hold the value of the checkbox until the form is reopened and
will show that value upon open.
"Solution4U" wrote:

I need help.

I have 3 userforms. Userform1 has 2 buttons, one to start a new project and
one that edits the project as saved. Which ever button is clicked brings up
userform2 which has 5 checkboxes.

What I would like to happen: when the edit button is clicked I would like
the checkboxes that were checked the last time to show up as checked. The
value of the checkboxes are stored on sheet3 in cells c2-c6.

Thank you for your time and assistance.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Show checkbox checked on open

I would save setting values to registry.

paste this code in a standard module: (rename Userform1 as appropriate)


Sub GetSettings()
' Reads default settings from the registry
Dim ctl As Control
Dim CtrlType As String

For Each ctl In UserForm1.Controls
CtrlType = TypeName(ctl)
If CtrlType = "CheckBox" Then

ctl.Value = GetSetting(AppName:="My Application", _
section:="CheckBox Settings", _
key:=ctl.Name, Default:=False)

End If
Next ctl
End Sub

Sub SaveSettings()
' Writes current settings to the registry
Dim ctl As Control
Dim CtrlType As String

For Each ctl In UserForm1.Controls
CtrlType = TypeName(ctl)
If CtrlType = "CheckBox" Then

SaveSetting AppName:="My Application", _
section:="CheckBox Settings", key:=ctl.Name, _
setting:=CStr(ctl.Value)

End If
Next ctl
End Sub

then add this code to the userform with checkboxes:


Private Sub EditButton_Click()
SaveSettings
'other code
End Sub

Private Sub UserForm_Initialize()
GetSettings
'other code
End Sub

hope helps
--
jb


"Solution4U" wrote:

I need help.

I have 3 userforms. Userform1 has 2 buttons, one to start a new project and
one that edits the project as saved. Which ever button is clicked brings up
userform2 which has 5 checkboxes.

What I would like to happen: when the edit button is clicked I would like
the checkboxes that were checked the last time to show up as checked. The
value of the checkboxes are stored on sheet3 in cells c2-c6.

Thank you for your time and assistance.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Show checkbox checked on open

The method suggested does not require code. In the properties dialog box for
each checkbox there is a Control Source property. Select that property and
type in a cell reference e.g. Sheet1!a1. Of course use a different cell
for each checkbox, and choose a cell that will not be accesssed by users in
the normal course of business to avoid inadvertant changes. The chosen cells
will show True if the checkbox is checked and False if the checkbox is blank.
These cell values are retained after the userform is closed and are
automatically loaded into the checkbox when the userform is initialized again.

"Solution4U" wrote:

Could you show me an example of code for that? I am rather new to vba.

Thank you for the response.

"JLGWhiz" wrote:

You could probably set up a linked cell (control source) for each checkbox
which would hold the value of the checkbox until the form is reopened and
will show that value upon open.
"Solution4U" wrote:

I need help.

I have 3 userforms. Userform1 has 2 buttons, one to start a new project and
one that edits the project as saved. Which ever button is clicked brings up
userform2 which has 5 checkboxes.

What I would like to happen: when the edit button is clicked I would like
the checkboxes that were checked the last time to show up as checked. The
value of the checkboxes are stored on sheet3 in cells c2-c6.

Thank you for your time and assistance.

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
Checkbox checked then show more checkboxes Sara New Users to Excel 3 September 10th 08 07:16 PM
How to have Checkbox A uncheck with checked Checkbox B Texas Aggie Excel Discussion (Misc queries) 3 July 20th 07 10:58 PM
Is checkbox is checked? Fred S Excel Discussion (Misc queries) 2 October 19th 05 03:53 AM
If Checkbox checked/notchecked then Darrin Henry[_2_] Excel Programming 2 April 13th 05 06:05 PM
checkbox - default checked or un-checked barrfly Excel Programming 1 December 22nd 03 05:00 PM


All times are GMT +1. The time now is 05:36 PM.

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"