Excel VBA form in multiple workbooks - vba

I have a form that makes list of values from selection as can be seen here:
I have added the opportunity to enter the list in Excel. I will select the cell and click on "Enter data in Excel":
But what I would like to do is to have the possibility to enter data to another workbook, but when I select another workbook the form is no longer active.
I know I can reference another workbook and other worksheets in VBA code, but I would like to have the possibility to select the cell in another workbook by clicking on it.

Change the form's ShowModal property to 'False'. This is found in the object property window when the object is selected in the Visual Basic editor. That should allow it to remain open when you change workbooks.

Related

Excel Form pops automatically when sheet opens

I have a specific worksheet with 2 sheets(Sheet1 & Sheet2). For Sheet2 I have implemented a form for the table (Using the basic Excel Form from the top bar).
My problem is that I have to make the form appear automatically every time I open Sheet1 (even if the data from the form will be completed in Sheet2).
Is this possible? Or how can I do it? (I can also use VBA)
To show the DataForm associated with a Worksheet, you use the command Worksheet.ShowDataForm (MSDN Article)
To show the DataForm for Sheet1 whenever you go to Sheet2, you can use the Worksheet_Activate event in Sheet2, like so:
Option Explicit
Private Sub Worksheet_Activate()
Sheet1.ShowDataForm
End Sub
A quick way to figure things like this out is use the "Record Macro" button, carry out the action you want, and then hit "Stop Recording" and look at the macro

Excel function Implemented on Access

I am working on a "inventory check" Excel worksheet that finds the item code and then inserts a timedate in a the date column.
Table has two Columns; 'Item Code' and 'Date'
I have made a macro on Excel that basically asks for item code, and inserts the date in the corresponding cell.
I am trying to implement this in Access. Does anyone have any references?
Not sure which version of Access so I'll try to be generic:
In Access - find the table and create a form from it (Usually by clicking a button on the toolbar).
Switch to design view in the form, in the header add a combo box using the control wizard and ask it to "Find a record in my form based...." - set it to the field "Item Code"
Set the visible property of the item code box in the detail section to False
create a macro to set a property - control is "Date", property to set is "Value", value to set it to is "=Now()"
Save this macro
Add a command button, in the wizard set it to run your saved macro

Set focus on ComboBox (ActiveX Control) after code execution

I have an Excel file with a combobox (name = "Combobox1"). After running a script (basically pasting the selected value in "the next row" of a column) I want the focus to be reset on the combobox at the end of the script, so doing allowing me to type the next entry in the Combobox without having to click on the ComboBox text field first.
This does the job in Excel 2013 but I would like to have it working in 2007 as well:
Combobox1.Activate
Anyone any idea?
Or:
I can replace the combobox with an in-cell dropdown list (data validation) and the same data validation as the one I have in the combobox at the moment, but then I have another issue:
For a ComboBox you can choose to have the dropdown list active, but for an in-cell data validation that is not the case, at least not if you want to be able to type in the cell after the list is shown with ALT+UP or
Application.SendKeys "%{UP}"
Any idea here?
If this combobox is on a worksheet and not a userform, then "Combobox1.select" should return the focus to the combobox.

Userform to specify workbook/worksheet to copy

I would really appreciate any help on the following....
I am looking to create a userform to import external worksheets from open workbooks into the current workbook - My aim is to use 2 drop down lists and one submit button:
First drop down box: Lists all open workbooks - User clicks to specify which is required.
Second box: Lists all worksheets within the selected workbook in the first box - User clicks to specify which is required.
Submit button: When submit is clicked, the macro will take a copy of the workbook/worksheet combination specified in the dropdown boxes and paste this as a new tab in the main workbook.
Thanks in advance.
You can list all workbooks and worksheets in a combo box like they did in this post
You can link the workbook / worksheet combo boxes by 'dependent drop down list', see this post. Note that you need an on-change event fired when the first combo value is selected in order to populate the second combo.
Finally, you can copy worksheets from another workbook as shown in this post

Unlock/lock form objects with vba

I have an excel worksheet with 2 comboboxes, and 3 scrollbars. I want to protect all the sheet except this form objects (and one cell). When i try to protect the sheet, i can't use the scrollbars and comboboxes. How can i unlock them, keepin the protection for the rest of the sheet with vba ? I tried to unlock the cells linked to the form objects but it still doesn't work.
Thank u
AB
Why not put the cells that need to be modified on a very hidden worksheet.
Create a named range e.g. "InputCell" in a separate worksheet e.g. "SheetWithInputCell". Set the cell link of the combobox to the named range using =InputCell.
Then set the worksheet to VeryHidden. VeryHidden means that users can't right-click on the sheet tabs and unhide it.
To set the sheet to very hidden, go to the VBA IDE (Alt+F11) and look at the Properties window. If you can't see the Properties window, select View > Properties Window.
In the Project Explorer window (View > Project Explorer), select the worksheet to hide and set the Visible property to xlSheetVeryHidden.
Then you can leave the hidden sheet unprotected and lock the sheet with the controls.
What about Menu option Data --> Allow Users to Edit Ranges?