coding for changes....

J

jeramie

i have a userform that shows at workbook open, and a shortcut key to reshow
it later if needed. the textboxes on the userform put names directly into
cells on the worksheet, then creates a filename and saves it. when i tab out
of a text box or click the command button, i need excel to check to see if
the corresponding cell is empty, and if not, is it different from the
textbox? if so, ask the user it he wants to keep the change.

i have this code in a macro module:

Sub TB3change()
If ThisWorkbook.Saved = True And UserForm1.Visible = True Then
With ThisWorkbook
If Worksheets("Page 1").Range("A3") <> "" And UserForm1.TextBox3.Text <>
"" Then
If UserForm1.TextBox3.Text = Worksheets("Page 1").Range("A3").Text
Then
Exit Sub
Else: UserForm1.TextBox3.SetFocus
If MsgBox("This entry has changed. Do You Want to keep this
change?", vbQuestion + vbYesNo, "Entry Exists") = vbYes Then
Worksheets("Page 1").Range("A3").Select
Application.Selection.Value = UserForm1.TextBox3.Text
Else: Exit Sub
End If
End If
End If
End With
End If
End Sub

any help would be greatly appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top