Userform to specify workbook/worksheet to copy - vba

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

Related

Excel VBA form in multiple workbooks

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.

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 checkboxes to hide and unhide rows disappear when i save and reopen file

I have 2 sheets in excel where if you tick the checkboxes on the first sheet it hides or unhides the rows on sheet2. I used active x controls and set checkbox properties to 'move and size with cells' but when i unhide the rows, the checkboxes disappear but are still in the document as their height changes and remains at 0.(the rows appear just fine). Please help!!
ActiveX checkboxes are reknown for problems like these. FOrms checkboxes are a bit better, but I would advise to just use cells with data validation set to list and have it accept 0/1 or True/False. It is relatively easy to set up an event macro that toggles the value of those cells after a double-click for instance.

Invoking the Activate dialog for sheets

I want to invoke the Activate dialog for sheets in a workbook such as below. This dialog can be called manually by right clicking on the arrow button at the bottom left of Excel (2013).
I tried this:
Application.Dialogs(xlDialogActivate).Show
But instead of showing the list of sheets, it shows the list of open workbooks:
How do I call the Activate dialog for sheets?
You could create your own dialog box if you want. Create a userForm and populate it with the names of the Worksheets upon activation. You can see what the user selected through the selected function, e.g.
ListBox1.Selected(i)
You can then call a sub with the name of the Sheet and activate it, e.g.
Sub ChangeSheet(SheetName)
Worksheets(SheetName).Activate
End Sub
An alternative is to show the Sheet Command bar:
Sub ShowSheets()
Application.CommandBars("Workbook tabs").ShowPopup
End Sub
Content salvaged from comments by Scott Holtzman and Davesexcel.

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?