I have a combo box with a pick list in excel.
The combo box fires on double click of a cell with validation
If the user then presses the escape key I wnat the linked cell to return to the previous value.
So far I have got the double click to copy the original value into cell "A1"
Then I have the following code on keystroke for the combo
This means if enter or tab are used the value is returned then copied and pasted over itself to fire an ON Change event.
I can't get the original back in with escape though, trying to copy it back from A1.
How do I get Excel to paste in the original target cell (the one that opened the combo), considering that cell could be anywhere in the worksheet because the combo box will fire on any cell with validation = 3.
The active cell changes to A1. This is why it won't paste in the correct place. How do I get it back to the original cell that called the combo from A1 after copying it?
The combo box fires on double click of a cell with validation
If the user then presses the escape key I wnat the linked cell to return to the previous value.
So far I have got the double click to copy the original value into cell "A1"
Then I have the following code on keystroke for the combo
Code:
Private Sub PickCombo_KeyDown(ByVal _
KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)
Application.ScreenUpdating = False
Select Case KeyCode
Case 27 'escape
Range("A1").Copy
ActiveCell.Offset(0, 1).Select
Application.ScreenUpdating = False
Selection.Offset(0, -1).Select
Application.ScreenUpdating = False
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Case 9 'Tab
Application.ScreenUpdating = False
ActiveCell.Offset(0, 1).Select
Application.ScreenUpdating = False
Selection.Offset(0, -1).Select
Application.ScreenUpdating = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Case 13 'Enter
ActiveCell.Offset(0, 1).Select
Application.ScreenUpdating = False
Selection.Offset(0, -1).Select
Application.ScreenUpdating = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Case Else
End Select
Application.ScreenUpdating = True
End Sub
I can't get the original back in with escape though, trying to copy it back from A1.
How do I get Excel to paste in the original target cell (the one that opened the combo), considering that cell could be anywhere in the worksheet because the combo box will fire on any cell with validation = 3.
The active cell changes to A1. This is why it won't paste in the correct place. How do I get it back to the original cell that called the combo from A1 after copying it?
Comment