Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default closng userform and canceling changes

I have userform that I would like to have access to on and off
throughout the usage of a spreadsheet. I want to ability to open it
and then cancel if the user decides that the changes are not necessary.
currently I have an OK and a Cancel button on the form. If the user
clicks OK, the input is written to the spreadsheet. If the user clicks
Cancel the form is hidden using UserForm1.Hide and the input,
regardless of any changes, is not written to the spreadsheet. my
problem is this: even though the input is not written to the
spreadsheet, it is saved within the userform. I do not want this. for
instance, if I open the form and checkbox1 is unchecked and I check it
then click Cancel, the form is hidden and nothing on the spreadsheet
changes. However, when I reopen the form, checkbox1 is still checked.
how can I fix this?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 205
Default closng userform and canceling changes

Hi Jacob,

I would split up the functionality a little cleanup code on each button
click event. So for example:

Private Sub UserForm_Initialize()
Call SetDefaultSettings
End Sub

Private Sub cmdOK_Click()
'Add values to workbook code
Call SetDefaultSettings
Me.Hide
End Sub

Private Sub cmdCancel_Click()
'Ignore add values to workbook code
Call SetDefaultSettings
Me.Hide
End Sub

Private Sub SetDefaultSettings()
Me.chkBox1.Value = False
'Plus other changes you want to make
End Sub

Hope that helps

Best regards

John

"Jacob" wrote in message
oups.com...
I have userform that I would like to have access to on and off
throughout the usage of a spreadsheet. I want to ability to open it
and then cancel if the user decides that the changes are not necessary.
currently I have an OK and a Cancel button on the form. If the user
clicks OK, the input is written to the spreadsheet. If the user clicks
Cancel the form is hidden using UserForm1.Hide and the input,
regardless of any changes, is not written to the spreadsheet. my
problem is this: even though the input is not written to the
spreadsheet, it is saved within the userform. I do not want this. for
instance, if I open the form and checkbox1 is unchecked and I check it
then click Cancel, the form is hidden and nothing on the spreadsheet
changes. However, when I reopen the form, checkbox1 is still checked.
how can I fix this?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default closng userform and canceling changes

Roedd <<John wedi ysgrifennu:

Hi Jacob,

I would split up the functionality a little cleanup code on each
button click event. So for example:

Private Sub UserForm_Initialize()
Call SetDefaultSettings
End Sub

Private Sub cmdOK_Click()
'Add values to workbook code
Call SetDefaultSettings
Me.Hide
End Sub

Private Sub cmdCancel_Click()
'Ignore add values to workbook code
Call SetDefaultSettings
Me.Hide
End Sub

Private Sub SetDefaultSettings()
Me.chkBox1.Value = False
'Plus other changes you want to make
End Sub


Or just call SetDefaultSettings from Userform_activate which will run every
time the form is unhidden.

Rob


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 205
Default closng userform and canceling changes

Ah, didn't know that one. Much simpler!

Thanks Rob

"Robert Bruce" <rob@analytical-dynamicsdotcodotukay wrote in message
...
Roedd <<John wedi ysgrifennu:

Hi Jacob,

I would split up the functionality a little cleanup code on each
button click event. So for example:

Private Sub UserForm_Initialize()
Call SetDefaultSettings
End Sub

Private Sub cmdOK_Click()
'Add values to workbook code
Call SetDefaultSettings
Me.Hide
End Sub

Private Sub cmdCancel_Click()
'Ignore add values to workbook code
Call SetDefaultSettings
Me.Hide
End Sub

Private Sub SetDefaultSettings()
Me.chkBox1.Value = False
'Plus other changes you want to make
End Sub


Or just call SetDefaultSettings from Userform_activate which will run
every
time the form is unhidden.

Rob




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default closng userform and canceling changes

thanks for the help.

John wrote:
Ah, didn't know that one. Much simpler!

Thanks Rob

"Robert Bruce" <rob@analytical-dynamicsdotcodotukay wrote in message
...
Roedd <<John wedi ysgrifennu:

Hi Jacob,

I would split up the functionality a little cleanup code on each
button click event. So for example:

Private Sub UserForm_Initialize()
Call SetDefaultSettings
End Sub

Private Sub cmdOK_Click()
'Add values to workbook code
Call SetDefaultSettings
Me.Hide
End Sub

Private Sub cmdCancel_Click()
'Ignore add values to workbook code
Call SetDefaultSettings
Me.Hide
End Sub

Private Sub SetDefaultSettings()
Me.chkBox1.Value = False
'Plus other changes you want to make
End Sub


Or just call SetDefaultSettings from Userform_activate which will run
every
time the form is unhidden.

Rob



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
Self canceling checkboxes Glenn Excel Discussion (Misc queries) 3 October 28th 08 03:11 PM
Canceling Workbook_BeforeClose does not work jforstrom Excel Programming 3 September 28th 06 01:11 PM
Canceling the rest of a Sub Rob Excel Programming 1 August 25th 06 04:29 PM
Canceling a print job Dan Scholler Excel Programming 2 August 9th 04 06:24 PM
Canceling a UserForm Eric W. Excel Programming 1 August 26th 03 06:56 PM


All times are GMT +1. The time now is 11:38 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"