Keep cell selection

J

Johnny E. Jensen

Hello NG

In a excel sheet i have 5 buttons. Colored red, green, blue, yellow and
purple.

The user must select some celles on the sheet and then click on a button.
The click should call a VBA code and place the button backcolor in the
selected cells.

My problem is that when the user clicks the button, the selected cells
disappears.
Is there a way to hold the selection until the user has clicked a button?

Kind regards

Johnny E. Jensen
 
R

Rick Rothstein

If you use CommandButton's from the Control Toolbox toolbar, then you can
set its TakeFocusOnClick property to False... do this will keep the cell
selection selected when the CommandButton's is clicked.
 
P

Paul

'Add this line to the start of your sub
cOldSelection = Selection.Address

' Add this one as the last line of your sub
Range(cOldSelection).Select
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top