Archive of Mr Excel Message Board


Back to Controls in Excel archive index
Back to archive home

Buttons

Posted by Tom on March 16, 2001 2:44 PM
Is there a way to fit a button to a cell other than by adjusting its size?

Re: Buttons

Posted by Dave Hawley on March 16, 2001 3:16 PM


Hi Tom

A macro will do the trick.

Sub AddButton()

ActiveSheet.OLEObjects.Add(ClassType:="Forms.CommandButton.1", Link:=False _
, DisplayAsIcon:=False, Left:=ActiveCell.Left, Top:=ActiveCell.Top, _
Width:=ActiveCell.Width, Height:=ActiveCell.Height).Select

End Sub


To use it Push Alt+F11, then go to Insert>Module and paste in the code. Push Alt+Q and save.

Now Push Alt+F8 select: "AddButton" Click Options and assign a shortcut key.


Dave


OzGrid Business Applications


This archive is from the original message board at www.MrExcel.com.
All contents © 1998-2004 MrExcel.com.
Visit our online store to buy searchable CD's with thousands of VBA and Excel answers.
Microsoft Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.