ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Increase decimal macro (https://www.excelbanter.com/excel-programming/289202-increase-decimal-macro.html)

R Avery

Increase decimal macro
 
I have the following problem:
I often want to change the position of the decimal place in a cel (i.e.,
change its NumberFormat). However, i am too lazy to use the toolbar button.
Instead, I need something i can bind to a shortcutkey. Unfortunately,
recording the macro yields no interesting results.

Is there a simple, general way to do what I am thinking of, or must the code
for such a macro be necessarily long?

Any help would be appreciated! Thanks.



Peter Atherton[_26_]

Increase decimal macro
 
something like

c=c.offset*17.5%
c.numberformat="0.00"

Peter
-----Original Message-----
I have the following problem:
I often want to change the position of the decimal place

in a cel (i.e.,
change its NumberFormat). However, i am too lazy to use

the toolbar button.
Instead, I need something i can bind to a shortcutkey.

Unfortunately,
recording the macro yields no interesting results.

Is there a simple, general way to do what I am thinking

of, or must the code
for such a macro be necessarily long?

Any help would be appreciated! Thanks.


.


R Avery

Increase decimal macro
 
I had not thought of doing that (didn't know it was possible)! Thanks,
Dave.





"Dave Peterson" wrote in message
...
You could write a routine that would parse the .numberformat of each cell

in the
selection, but man, there's lots of .numberformats that those buttons

respect!

Maybe just running the buttons:

Option Explicit
Sub increaseDecimal()
Application.CommandBars("formatting").FindControl( ID:=398).Execute
End Sub
Sub decreasedecimal()
Application.CommandBars("formatting").FindControl( ID:=399).Execute
End Sub




R Avery wrote:

No, what I am looking for is a lot more general.

I want to have a macro called "IncrementDecimal", or something like

that, so
that when i press the shortcutkey it is bound to, it will increase the
decimal of all cells in the selection by 1, just like the button on the
toolbar.

Similarly, I would want a "DecrementDecimal" macro that would do the
reverse.

For example, if i had cells A1:A3 like this
$1,030.45
45.813%
1.1

Then the "DecrementDecimal" macro would, if A1:A3 is selected, change it

to
the following:
$1,030.5
45.81%
1


--

Dave Peterson





All times are GMT +1. The time now is 10:02 PM.

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