by Allen Wyatt
(last updated June 29, 2013)
Robin asked a question concerning an oddity in Excel. She creates a worksheet that contains a button drawn using the Forms toolbar, and assigns a macro to the button. The button works fine until the worksheet is protected, then the entire top section of the worksheet acts as a button. (The hand icon appears no matter where you move the mouse, and when you click the macro executes—you don't have to click on the button itself.)
The problem does not occur with all items from the Forms toolbar, but only occurs under certain circumstances. It primarily occurs because a macro button is associated with a cell (such as cell B2), and then the cell is deleted. This means the button is essentially "unattached," so Excel is confused as to where the button belongs. When the worksheet is protected, Excel acts oddly because it believes that the button is "everywhere" since it doesn't really know where the button belongs.
The obvious solution is to make sure that the macro button is always attached to a cell that doesn't get deleted. Unprotect the workbook, select the sliver of the button near the column headers, and move it to a cell you want to associate it with. Reprotect the worksheet and the odd behavior should disappear.
If you cannot see the button that is causing the problem, it could be because it is too small. The solution to that situation is to run a macro that searches for all the buttons in the worksheet and makes them visible. On the unprotected worksheet, run the following:
Sub CheckShapes() Dim myShape As Shape For Each myShape In ActiveSheet.Shapes With myShape If .Height < 2 Then .Height = 20 If .Width < 2 Then .Width = 20 End With Next myShape End Sub
The macro steps through all the shapes in the worksheet and, if they have a height or width less than 2 pixels, increases their height and width so they are visible. Now you should be able to see the macro button and can drag it to a location on the worksheet or delete it.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2830) applies to Microsoft Excel 97, 2000, 2002, and 2003.
Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!
Macros give you a great deal of control over creating, finding, renaming, and deleting files. This tip focuses on this last ...Discover More
People often place macros in template files to perform any number of tasks. This tip describes a situation where the link ...Discover More
Need to move a macro out of your Personal.xls workbook and into a regular workbook? You can do it using familiar editing ...Discover More
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.