This FAQ refers to CONTROLS toolbox command buttons which have far more properties than the old FORMS collection buttons. More will appear here but this is for starters as IMO, it is the most common error associated with commandbuttons.
1: I get a "1004" or "'9 subscript out of range" error when trying to run code from a button (ie the click event) BUT the code runs fine when run through the VBE / debug window
This is caused 99 times out of 100 by not setting the "TakeFocusOnClick" property of the command button to false. Many actions on ranges / sheets need the object to have the focus. Unless this property is changed, the focus goes straight to the command button and the code errors with either a "1004" or "'9 Subscript" error
The steps need to resolve this are:
1. Make sure you are in "design mode" (little blue set square)
2. Right click on the button
3. Choose "properties"
4. Select the "Take Focus On Click" property and change to FALSE
5. exit properties
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.