ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to assign keyboard shortcut to existing Commandbar controls (https://www.excelbanter.com/excel-programming/364650-how-assign-keyboard-shortcut-existing-commandbar-controls.html)

superjas

How to assign keyboard shortcut to existing Commandbar controls
 
Hi,

I wish to assign a keyboard shortcut (eg CTRL + SHIFT + D) to the command
control id 398, which changes the formatting of a cell to show another
decimal place.

Could you please show me how it's done?

Many thanks in advance!

Norman Jones

How to assign keyboard shortcut to existing Commandbar controls
 
Hi Superjas,

Copy the following macro into a standard module in your Personal.xls
workbook.

'=============
Public Sub IncreaseDecimals()
Application.CommandBars("Formatting"). _
FindControl(ID:=398).Execute
End Sub
'<<=============

Then, either assign the shortcut key combination to the macro manually or
try:

'=============
Public Sub Tester()
Const WbName As String = "Personal.xls" '<<==== CHANGE
Application.MacroOptions Macro:=WbName & "!IncreaseDecimals", _
Description:="", ShortcutKey:="D"
End Sub
'<<=============



---
Regards,
Norman


"superjas" wrote in message
...
Hi,

I wish to assign a keyboard shortcut (eg CTRL + SHIFT + D) to the command
control id 398, which changes the formatting of a cell to show another
decimal place.

Could you please show me how it's done?

Many thanks in advance!




superjas

How to assign keyboard shortcut to existing Commandbar control
 
Hi Norman,

That's awesome, exactly what I was after! Thankyou very much!!

Cheers!


All times are GMT +1. The time now is 04:43 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com