Opening another Workbook and displaying the Userform and closing the original Workbook and Userform

markgrnh

New Member
Joined
Apr 7, 2023
Messages
18
Office Version
  1. 365
Platform
  1. Windows
Good morning,

I have created a VBA reporting tool using a VBA Userform and as its become really useful, I have now been asked to recreate another just like it for another of the companies in our group and then have a front end dashboard that allows you to select the company you want and it then opens up that particular workbook.

I have managed to get the workbooks to open and close but as they both have Userforms which should open when the workbook is started, yet on the company workbook (2nd spreadsheet, opened by the first) it loads the worksheet but not the userform.

The original workbook that is now used to open the individual company workbook is fine and that displays the Userform on opening and closes on command, but how do I force the 2nd sheet to display the userform rather than the actual spreadsheet?

I have tried setting the Workbook Open command to display the Userform and that works if I open the workbook myself manually but not when done via VBA code.

I have set the ShowModal as false on both Userforms thinking that might be an issue, but still no luck and I am sure its something simple, yet for the life of me I just cant work it out.

I hope that all makes sense?

For ease lets say the workbook with the buttons to select the company you want is Workbook 1 and the actual Company spreadsheet is Workbook 2 and they are currently saved in the same folder at the moment.

Any suggestions would be appreciated?

This is the code for the company sheet (Workbook2), reporting tool v1 being the original that closes (Workbook1), when this sheet opens:

1684751617446.png



Thanks

Mark
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Hi markgrnh. You can adjust this code to suit. In the wb to be opened...
ThisWorkbook code...
Code:
Private Sub Workbook_Open()
Sheets("Sheet1").Range("A" & 1) = 1
Sheets("Sheet1").Range("A" & 2).Select
End Sub
Sheet code....
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Sheets("Sheet1").Range("A" & 1) = 1 Then
UserForm1.Show
Sheets("Sheet1").Range("A" & 1) = vbNullString
End If
End Sub
HTH. Dave
 
Upvote 0
Sorry for the late reply, but not had chance to test your solution yet, as got sidetracked onto another project and had some much needed holiday but I will test this shortly and tag the results. Many thanks for your answer though and apologies again for the untimely response.
 
Upvote 0

Forum statistics

Threads
1,214,648
Messages
6,120,726
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top