![]() |
Key modifier for double-click event?
Is it possible to detect if a key is held down during th
BeforeDoubleClick event? I want to be able to change a cell with a double-click, but no interfere with the normal edit formula default functionality. I want t be able to hold down the CTRL key while double-clicking the cell to ge different behavior. Is this possible? TIA, - -- Message posted from http://www.ExcelForum.com |
Key modifier for double-click event?
Byrt,
I believe you are going to have to use a key other than the Ctrl or Shift key. The Alt key will work... '1. Place the following line of code at the top of a general module: Public Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer '2. Then your code in the double click event for the sheet could look like this: '-------------------------------------------- Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) If GetKeyState(18) < 0 Then 'more code MsgBox "Alt key is down" Else 'more code MsgBox "Alt key is up" End If Cancel = True End Sub '--------------------------------------------- The Shift key is "16", the Ctrl key is "17" and the Alt key is "18". Regards, Jim Cone San Francisco, CA "Byrt Martinez " wrote in message ... Is it possible to detect if a key is held down during the BeforeDoubleClick event? I want to be able to change a cell with a double-click, but not interfere with the normal edit formula default functionality. I want to be able to hold down the CTRL key while double-clicking the cell to get different behavior. Is this possible? TIA, -B |
All times are GMT +1. The time now is 08:15 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com