I'm working with VBA in Excel 2007.
When I click on my checkbox, I have to do it 2 times before the check mark appears. I have no idea what can cause that. Can somebody help me?
This behaviour is normal when the Excel application is not the active one on your screen (= doesn't have the focus)
the first click is to activate the Excel application window
the second click is to work inside the application.
This applies to Form or ActiveX checkboxes embedded a sheet, it even happens when you want to select a certain cell (say C2) ... when Excel was inactive, the first click (into C3) activates the application and shows the cursor at its previous location (say B3), second click will move cursor to C3.
User forms behave a bit different. Even when they have no focus at first, once you click into a checkbox inside the user form, it activates AND processes the checkbox - except if you trick it out by an event trigger (there are a few that could come in here)
Related
I would love to activate insertion in one Column in my Excel sheet but diable it in the rest columns . I use Protect sheet but it protects all my sheet.
How Can I make only one column enabled and the rest disabled ?
Thank you in advance !
Select the whole sheet using the very top-left square in the sheet
On the Home tab, in the Alignment group, click the small arrow to open the Format Cells popup window.
On the Protection tab, select the Locked check box, and then click OK to close the popup.
Select the column you wish to be enabled
repeat step 2
On the Protection tab, unselect the Locked check box, and then click OK to close the popup.
On the Review tab in the ribbon, in the Changes group, select Protect Sheet
Partial source https://support.microsoft.com/en-us/office/lock-cells-to-protect-them-cb7835f6-9c37-4161-bb53-d1c410acaf21
I've just started a new contract and am working with Office VBA again after about 20 years. There is a spreadsheet I'm working on where command buttons disappear after the document saves. I've been reading other threads that suggest as a fix setting the size of the button after saving. However, I can't figure out how to identify that button in code.
When I click "Format", there is no place where the name of the object appears. There's a macro attached to it, but I see no way to identify the "sender" when the macro fires.
The macro pops up a form, and after the user enters some information and submits, it saves the sheet, and the button goes "poof".
Is there any way to get the name of the button in the macro so I can resize it?
Thanks!
If you right-click the button, its name appears in the upper left hand corner of the spreadsheet in the Developer ribbon, right below the "Visual Basic" and "Macros" menu items. In my case, it was "Button 1".
Accessing it was non-intuitive for a guy used to working with full-blown .NET apps, but the button is a "Shape". So, addressing the button is accomplished with the identifier ActiveSheet.Shapes("Button 1"). With this object, you can access its properties and methods.
I'm new to using VB w/ excel, so please forgive my lack of technical verbiage.
I recently received a new laptop, and transfered an excel file from my old laptop with VB setup to automatically generate reports. On the new laptop, when I click on my Active X Command Buttons, a smaller duplicate button appears. For some of these buttons, I can double click and the needed action is performed if that second button is under my mouse icon. For others (see picture), this second button displays, but when I move my mouse to get to it, it disappears.
Any help in resolving this would be greatly appreciated.
Try to select one button and use 'Tab' Key to select next one
Is it possible to have a macro that, when pressed, pops up a message box asking for a string of text, and then a drop down that has a list of categories?
All I would need it to do is take this information and save it into a cell. If so, how?
[I'm going based on Excel 2007 here, but if you're using 2003, you'll have to navigate the menu structure]
Go to the VBE (by going to the View tab, then click on Macro - creating or editing an existing one will take you there - or click Alt+F11).
Go to the Insert menu, and select Userform. Drag a textbox (the ab|icon), and a combobox onto your form. To set the textbox value to a cell when you change the combobox, create a subroutine in the code to do this by double clicking on the combobox.
Set the combobox items by using the .additem method of comboBox1 in your code. These can be delineated or grabbed from a range in your code (see here)
Within that subroutine, set the value of whatever cell you want to textbox1.Text, which is the contents of the textbox.
I wanted to know after I initialize a combobox, is there a possibility that I can still stay active with the background Excel sheet using the cursor like scroll the sheet up/down, type words on the sheet, etc?
(While at the same time the combobox still stays on top of the Excel sheet doing whatever event you might want to do with your VBA?)
Go to the VBA IDE and select your form. In the properties list (on the left hand side of the screen), find the ShowModal property. Set this to False.
This will prevent the dialog from taking over the window.