djburnheim
Technical User
I've got a simple form that displays values from cells in an excel workbook and I'm trying to find a simple way of checking to see if a user makes any changes in the form so I can update the workbook if needed. I can think of 2 ways of doing it but both seem long winded any other suggestions?
Many thanks
Dave
______________
Option 1
Use if then statement to check that form value = cell value for each control in the form
Private Sub cmdClose_Click()
Dim Userchange as Boolean
If UserForm.TextBox1 <> Sheets("Sheet1"
.Range("A1"
Then
UserChange = True
End If
'Repeat for each control on form
If UserChange = True Then
'msgbox prompting user to save changes
End If
End Sub
_______________
Option 2
Have a change event for each control
Dim Userchange as boolean
Private Sub TextBox1_Change()
Userchange = True
End Sub
Private Sub cmdClose_Click
If UserChange = True Then
'msgbox prompting user to save changes
End if
End Sub
______________
Many thanks
Dave
______________
Option 1
Use if then statement to check that form value = cell value for each control in the form
Private Sub cmdClose_Click()
Dim Userchange as Boolean
If UserForm.TextBox1 <> Sheets("Sheet1"
UserChange = True
End If
'Repeat for each control on form
If UserChange = True Then
'msgbox prompting user to save changes
End If
End Sub
_______________
Option 2
Have a change event for each control
Dim Userchange as boolean
Private Sub TextBox1_Change()
Userchange = True
End Sub
Private Sub cmdClose_Click
If UserChange = True Then
'msgbox prompting user to save changes
End if
End Sub
______________