Command button position and screen resolution

P

Palpha32

I have a worksheet that has four command buttons to run macros. If it is
used on a computer with a different screen resolution the buttons are in a
different position. Is there a way of anchoring the buttons to a point on
the worksheet so that they are in the same position, relarive to the cells,
no matter what the resolution?
Thanks in advance for your help.

Regards
Peter
 
R

Rick Rothstein

I think this workbook event code might do what you want (change the cell
assignment to the cell you actually want to "attach" to)...

Private Sub Workbook_Open()
Dim R As Range
Set R = Range("D4")
With ActiveSheet.CommandButton1
.Left = R.Left + R.Width
.Top = R.Top
End With
End Sub

To implement it, right click the XL icon to the left of the File menu item
and select View Code from the popup menu that appears and copy/paste the
above code into the code window that appeared. Now, whenever the workbook is
opened (and macros are enabled), the button will move into position next to
the specified cell.
 

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