ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Shortcuts for toolbar buttons/view code of toolbar buttons (https://www.excelbanter.com/excel-programming/393963-shortcuts-toolbar-buttons-view-code-toolbar-buttons.html)

ericm[_2_]

Shortcuts for toolbar buttons/view code of toolbar buttons
 
I would like to simply create a keyboard shortcut for some of the
toolbar buttons, namely the "Increase/Decrease Decimal" buttons.

I tried just recording them, but it records the action specific to the
recorded cell, -- i.e. if the cell that I record using the "Increase
Decimal" button on has 2 digits to the right of the decimal, the macro
will record

Selection.NumberFormat = "0.000"

The problem is, this recorded macro will set the number format to
three decimals, no matter how many decimal places are currently
displayed. I could do a workaround using if then statements, but this
made me wonder how I could either view the code that the toolbar
buttons use, or just assign a keyboard shortcut to existing toolbar
buttons.

Any ideas?


Tom Ogilvy

Shortcuts for toolbar buttons/view code of toolbar buttons
 
these would work on the activecell:

Dim cIncrease as CommandBarButton
Dim cDecrease as CommandBarButton
set cIncrease = CommandBars("Formatting").FindControl(ID:=398)
cIncrease.Execute
set cDecrease = CommandBars("Formatting").FindControl(ID:=399)
cDecrease.Execute

--
Regards,
Tom Ogilvy



"ericm" wrote:

I would like to simply create a keyboard shortcut for some of the
toolbar buttons, namely the "Increase/Decrease Decimal" buttons.

I tried just recording them, but it records the action specific to the
recorded cell, -- i.e. if the cell that I record using the "Increase
Decimal" button on has 2 digits to the right of the decimal, the macro
will record

Selection.NumberFormat = "0.000"

The problem is, this recorded macro will set the number format to
three decimals, no matter how many decimal places are currently
displayed. I could do a workaround using if then statements, but this
made me wonder how I could either view the code that the toolbar
buttons use, or just assign a keyboard shortcut to existing toolbar
buttons.

Any ideas?



ericm[_2_]

Shortcuts for toolbar buttons/view code of toolbar buttons
 
On Jul 23, 2:00 pm, Tom Ogilvy
wrote:
these would work on the activecell:

Dim cIncrease as CommandBarButton
Dim cDecrease as CommandBarButton
set cIncrease = CommandBars("Formatting").FindControl(ID:=398)
cIncrease.Execute
set cDecrease = CommandBars("Formatting").FindControl(ID:=399)
cDecrease.Execute

--
Regards,
Tom Ogilvy



"ericm" wrote:
I would like to simply create a keyboard shortcut for some of the
toolbar buttons, namely the "Increase/Decrease Decimal" buttons.


I tried just recording them, but it records the action specific to the
recorded cell, -- i.e. if the cell that I record using the "Increase
Decimal" button on has 2 digits to the right of the decimal, the macro
will record


Selection.NumberFormat = "0.000"


The problem is, this recorded macro will set the number format to
three decimals, no matter how many decimal places are currently
displayed. I could do a workaround using if then statements, but this
made me wonder how I could either view the code that the toolbar
buttons use, or just assign a keyboard shortcut to existing toolbar
buttons.


Any ideas?- Hide quoted text -


- Show quoted text -


Works great, thanks.



All times are GMT +1. The time now is 08:28 AM.

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