ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Command Button (https://www.excelbanter.com/excel-programming/288699-command-button.html)

wjd01

Command Button
 
Hello,

I hope someone can help with my question.
Is it possible to have one macro, that when activated by a
command button, make the cell beneath the command button
active? For example, I would have 10 command buttons on
cells C11 thru C20 (one over each cell). If any one of
these are clicked, the cell beneath is now the active
cell.
I'm trying to avoid having 10 individual macros assigned
to the buttons (one per button). I just wasn't sure if
one simple macro could be written that takes into account
the buttons position for setting the active cell.

Thanks in advance,
wjd01

Jim Rech

Command Button
 
If you use buttons from the Forms toolbar they can all have the same macro:

ActiveSheet.Buttons(Application.Caller).TopLeftCel l.Select

If you're using the Control Toolbox command button it may be harder...

--
Jim Rech
Excel MVP



wjd01

Command Button
 
Thanks Jim. This worked perfectly.

wjd01
-----Original Message-----
If you use buttons from the Forms toolbar they can all

have the same macro:

ActiveSheet.Buttons

(Application.Caller).TopLeftCell.Select

If you're using the Control Toolbox command button it may

be harder...

--
Jim Rech
Excel MVP


.



All times are GMT +1. The time now is 12:07 PM.

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