|
-
Apr 6th, 2006, 10:58 AM
#1
Thread Starter
Hyperactive Member
Excel VBA- Is there a way to trap a key entry?
I am trying to trap the key entered into an excel spreadsheet. Does anyone know how I can accomplish that?
Thank you!
-
Apr 6th, 2006, 11:02 AM
#2
Re: Excel VBA- Is there a way to trap a key entry?
Any key press, a specific key, or entry in a specific cell?
Please give us some more detail on what you are trying to achieve.
Declan
Don't forget to mark your Thread as resolved.
Take a moment to rate posts that you think are helpful 
-
Apr 6th, 2006, 11:15 AM
#3
Thread Starter
Hyperactive Member
Re: Excel VBA- Is there a way to trap a key entry?
I want to trap any key that is pressed on a given worksheet.
I know there is a keypress and keyup and keydown events, but I don't believe they apply to worksheets, only forms.
-
Apr 7th, 2006, 10:42 PM
#4
Fanatic Member
Re: Excel VBA- Is there a way to trap a key entry?
There is a Worksheet Change event that might serve your needs. If a cell is changed (by keyboard entry, paste, or vb program), the event fires exposing the cell address. You could then find out the contents of the cell to determine what the keystrokes were. Kind of indirect, but maybe good enough.
VB Code:
Private Sub Worksheet_Change(ByVal target As Excel.Range)
Debug.Print target.value
End Sub
-
Apr 10th, 2006, 03:06 PM
#5
Thread Starter
Hyperactive Member
Re: Excel VBA- Is there a way to trap a key entry?
This doesn't work for the delete key. It doesn't trigger the change event when the delete key is pressed.
Any other ideas?
-
Apr 10th, 2006, 03:35 PM
#6
Re: Excel VBA- Is there a way to trap a key entry?
There are no Keypress, keyup or keydown events for a cell.
What are you trying to do?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 10th, 2006, 03:39 PM
#7
Thread Starter
Hyperactive Member
Re: Excel VBA- Is there a way to trap a key entry?
When the delete key is pressed on a particular sheet meeting certain criteria, I want to basically control what they are trying to delete and only allow it under certain conditions.
-
Apr 10th, 2006, 08:01 PM
#8
Re: Excel VBA- Is there a way to trap a key entry?
You may have to end up protecting the sheet and if its a certain user then unprotect it?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|