by Allen Wyatt
(last updated June 23, 2018)
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.
Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!
Excel allows you to hide worksheets so that they aren't visible to those using your workbook. Hiding worksheets has a ...Discover More
An Excel workbook can contain quite a few different objects. Sometimes those objects can be hidden so that they are not ...Discover More
Need to access the advanced capabilities of a printer from within an Excel macro? You may be out of luck, unless you ...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.