hansgrandia
Board Regular
- Joined
- Jan 10, 2015
- Messages
- 53
Hello,
Below standing code pops-up after worksheet-change event. I'm looking for a piece of code that ends after pressing "cancel" (and revert to previous value) or ends when no name is entered (and also revert to last entered value of the cell). Name in the offset function should only change when person enters his/her name. When user pressed enter of no name, the name should be the same.
The code puts "name" (naam) on false in after pressing cancel and does not react when no value is entered.
Any help is appreciated! Regards,
Hans
Netherlands
Sub GoToName()
Dim Naam As String
Naam = Application.InputBox("What is your name?", Type:=2)
If Naam = "" Then
Exit Sub
Application.EnableEvents = False
Application.Undo
Application.EnableEvents = True
MsgBox "Forgot to enter name", vbExclamation
End If
If Naam = vbNullString Then
Exit Sub
End If
Application.EnableEvents = False
Application.Undo
Application.EnableEvents = True
ActiveCell.Offset(0, 5).Value = Naam
End Sub
Below standing code pops-up after worksheet-change event. I'm looking for a piece of code that ends after pressing "cancel" (and revert to previous value) or ends when no name is entered (and also revert to last entered value of the cell). Name in the offset function should only change when person enters his/her name. When user pressed enter of no name, the name should be the same.
The code puts "name" (naam) on false in after pressing cancel and does not react when no value is entered.
Any help is appreciated! Regards,
Hans
Netherlands
Sub GoToName()
Dim Naam As String
Naam = Application.InputBox("What is your name?", Type:=2)
If Naam = "" Then
Exit Sub
Application.EnableEvents = False
Application.Undo
Application.EnableEvents = True
MsgBox "Forgot to enter name", vbExclamation
End If
If Naam = vbNullString Then
Exit Sub
End If
Application.EnableEvents = False
Application.Undo
Application.EnableEvents = True
ActiveCell.Offset(0, 5).Value = Naam
End Sub