Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have an input userform that has OK, Cancel and Clear buttons. when
you input something and click OK, it writes it to a spreadsheet. If you click Cancel it closes the form an does not input anything. If you click clear, it clears all the values in the form. it clears it by clearing the contents of the spreadsheet then reactivating the form which reads the input from the cells. I tried to write a sub so that when you clear the input and then click cancel, the input will return to what it was before clicking on clear (when the form is opened again). here ar ethe subs for Cancel and Clear: Private Sub CommandButtonCLear_Click() Sheets("sheet1").Range("D34:H39").Value = Sheets("sheet1").Range("B8:F13").Value Sheets("sheet1").Range("B8:F13").ClearContents Unload UserFormMultiLC UserFormMultiLC.Show Sheets("sheet1").Range("D33").Value = 1 End Sub ---------------------------------------------------------------------------------------------------------------------------------------- Private Sub CommandButtonMultiLCCancel_Click() If Sheets("sheet1").Range("D33").Value = 1 Then Sheets("sheet1").Range("B8:F13").Value = Sheets("sheet1").Range("D34:H39").Value Else End If UserFormMultiLC.Hide End Sub the clear sub is working fine. it writes the input range to a new range before clearing the input range and restarting the userform. but when I click the cancel button, it is not writing the saved input range. into the original input range. I cannot understand why. does this make sense? is there a better way to go about this? thanks. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
userform label double-click goes to click event | Excel Programming | |||
Select Multi in Listbox - Event Click not working | Excel Programming | |||
Click event to run only once | Excel Programming | |||
Click event to run only once | Excel Programming | |||
Click Event | Excel Programming |