+ Reply to Thread
Results 1 to 12 of 12

I need VBA code to make each combobox option on a userform open an excel workbook ...

Hybrid View

  1. #1
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2505
    Posts
    27,243

    Re: I need VBA code to make each combobox option on a userform open an excel workbook ...

    Inactive and unresponsive mean two completely different things. Do you mean that the file opens but does not have focus? Or do you mean that the file opens but does not respond to any user input?

    I have not tested this but this form of the command may solve it:

    Formula: copy to clipboard
     Workbooks.Open(Filename:="Workbook A").Activate


    If you continue to have problems I will try to set up a test.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  2. #2
    Registered User
    Join Date
    09-22-2014
    Location
    Wellingborough, England
    MS-Off Ver
    Microsoft Office 2016 Professional
    Posts
    49

    Re: I need VBA code to make each combobox option on a userform open an excel workbook ...

    I appreciate your time and effort but that didn't work.

    I have "Workbook 1" which has a userform (combobox) on it. The userform opens other "Workbooks A to H" depending on what is selected in the userform and after open file is clicked.

    By unresponsive I mean that when the new "Workbook A" initially opens, no items on the menu bar work (File, Home, Insert, Page Layout, etc).
    But if I click back onto the original "Workbook 1" with the userform the menu items on that workbook work OK...
    I then click back onto the new "Workbook A" again and the menu items now work Ok as well.

    I've tried it with Unload Me in the code and without Unload Me in the code but that makes no difference.

    I hope I've explained my problem clearly now.
    I've pasted the code I have so far below ...



    Private Sub cbFiles_Change()

    Image1.Picture = LoadPicture(ThisWorkbook.Path & "\" & cbFiles.Value & ".jpg")

    End Sub

    Private Sub cmdOpen_Click()

    If cbFiles.Value = "" Then
    If MsgBox("You have not selected anything yet. If you continue this selection box will close. Do you want to continue?", vbQuestion + vbYesNo) <> vbYes Then
    Exit Sub
    End If
    End If

    Select Case Me.cbFiles
    Case "QTR1"
    Workbooks.Open(Filename:="C:\Users\Paul\Documents\Workbook A.xlsx").Activate
    Case "QTR2"
    Workbooks.Open(Filename:="C:\Users\Paul\Documents\Workbook B.xlsx").Activate
    Case "QTR3"
    Workbooks.Open(Filename:="C:\Users\Paul\Documents\Workbook C.xlsx").Activate
    Case "QTR4"
    Workbooks.Open(Filename:="C:\Users\Paul\Documents\Workbook D.xlsx").Activate
    Case "Daily Audits Completed QTR1"
    Workbooks.Open(Filename:="C:\Users\Paul\Documents\Workbook E.xlsx").Activate
    Case "Daily Audits Completed QTR2"
    Workbooks.Open(Filename:="C:\Users\Paul\Documents\Workbook F.xlsx").Activate
    Case "Daily Audits Completed QTR3"
    Workbooks.Open(Filename:="C:\Users\Paul\Documents\Workbook G.xlsx").Activate
    Case "Daily Audits Completed QTR4"
    Workbooks.Open(Filename:="C:\Users\Paul\Documents\Workbook H.xlsx").Activate
    End Select

    Unload Me

    End Sub

    Private Sub cmdClose_Click()

    Unload Me

    End Sub
    Last edited by Jalica; 09-15-2016 at 12:44 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Populating ComboBox based on Option button in excel userform
    By dotchiejack in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-05-2016, 07:41 AM
  2. how to make workbook open code specific to a sheet
    By whitwoo in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-18-2014, 01:16 PM
  3. Returning the row number of the option after the selected option in a userform combobox
    By rep67439fgs in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-30-2014, 08:07 AM
  4. UserForm help - display list of open workbooks except workbook userform code is in
    By kensweep in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-09-2014, 12:26 PM
  5. [SOLVED] Make combobox list options dependant on selection in another combobox within a userform
    By Vladimir_Dobvchenko in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-23-2013, 05:30 AM
  6. [SOLVED] Open UserForm when workbook opens (and not the code editor)
    By GavJ in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-12-2013, 02:12 AM
  7. [SOLVED] Wanna make a Userform Close and Save - Then open a different workbook?
    By Wanting2Excel in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-06-2012, 08:29 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1