MrExcel Publishing
Your One Stop for Excel Tips & Solutions


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?

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.


OzGrid Business Applications