+ Reply to Thread
Results 1 to 11 of 11

Show modal to False works, but now....How to specify a specific workbook in VBA

  1. #1
    Registered User
    Join Date
    08-16-2012
    Location
    Florida
    MS-Off Ver
    Excel 2016
    Posts
    33

    Show modal to False works, but now....How to specify a specific workbook in VBA

    OK, this should be pretty basic (I hope), and I feel kind of silly for not knowing how do to this....

    My wife busted my chops about my latest and greatest userform, because she cannot use any other spreadsheets when it is running. I did some research and found the showmodal to false in the properties, and that does seem to let me play in other sheets. The only problem is that if one does not click back on the specific spreadsheet for the userform, my macros crash. I am 100% certain that it is happening because of the way I am defining where to find my data:

    Please Login or Register  to view this content.
    The way it seems to work is that if I click on the right workbook, to make it "active", everything is perfect. How do I tell it to not look in the active workbook, but to always look in the #assperwk sheet of the BobMCCommentPrep.xlsm?

    I will also be writing to other sheets in the same workbook.

    Thank you in advance, and happy New Year.

    BobR

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,440

    Re: Show modal to False works, but now....How to specify a specific workbook in VBA

    ThisWorkbook is the workbook running the macros.

    Please Login or Register  to view this content.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    08-16-2012
    Location
    Florida
    MS-Off Ver
    Excel 2016
    Posts
    33

    Re: Show modal to False works, but now....How to specify a specific workbook in VBA

    Thank you TMS.

    I tried BobMCCommentPrep.xlsm.worksheets... and BobMCCommentPrep.worksheets.... and both are giving me a 424 object required error. This is what I used:

    Please Login or Register  to view this content.
    What did I do wrong?

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,440

    Re: Show modal to False works, but now....How to specify a specific workbook in VBA

    That wasn't what I said. Did you try copying and pasting what I posted? "ThisWorkbook" always refers to the workbook with the macros in it. If you need to fully qualify the workbook, you'd use:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    08-16-2012
    Location
    Florida
    MS-Off Ver
    Excel 2016
    Posts
    33

    Re: Show modal to False works, but now....How to specify a specific workbook in VBA

    Sorry, I misunderstood.

    I tried the new code, and it is back to giving me a run time error #9 - Subscript out of range, if I am not actively in the BobMCCommentPrep workbook. Anything else I might be missing? Here is the relevant part of the code:

    Please Login or Register  to view this content.
    When I debug, it is highlighting the first VLookup.

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,440

    Re: Show modal to False works, but now....How to specify a specific workbook in VBA

    Then it's not to do with ws. Which workbook is Sheets("CurrentWk") in? That's the only thing that's indexed.

  7. #7
    Registered User
    Join Date
    08-16-2012
    Location
    Florida
    MS-Off Ver
    Excel 2016
    Posts
    33

    Re: Show modal to False works, but now....How to specify a specific workbook in VBA

    Doh!

    OK, Same workbook. That is only one section of my lookups. Looking at it now, I see that I am looking through about 6 different sheets. Is it ok to just do the set ws multiple times?

  8. #8
    Registered User
    Join Date
    08-16-2012
    Location
    Florida
    MS-Off Ver
    Excel 2016
    Posts
    33

    Re: Show modal to False works, but now....How to specify a specific workbook in VBA

    OK, I got it. I just needed to add the workbook to the vlookup explicitly

    Please Login or Register  to view this content.
    Thank you very much

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,440

    Re: Show modal to False works, but now....How to specify a specific workbook in VBA

    You're welcome.

  10. #10
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Show modal to False works, but now....How to specify a specific workbook in VBA

    If I may suggest version for easier maintaining:
    Please Login or Register  to view this content.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  11. #11
    Registered User
    Join Date
    08-16-2012
    Location
    Florida
    MS-Off Ver
    Excel 2016
    Posts
    33

    Re: Show modal to False works, but now....How to specify a specific workbook in VBA

    That is awesome. Thank you.

    The problem with being completely self taught, is that the teacher does not ever know any better.

    I figured out the vlookup thing last year and have been using the heck out of it. I will look further into the with blocks, as it appears to tighten things up considerably. I am still in brute force and ignorance mode, and hope to graduate to a little finesse next year.

+ 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. [SOLVED] Formula SUMPRODUCT works, now needs some tweaking, to True/False identify TEXT
    By steve08087 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-29-2013, 06:20 PM
  2. [SOLVED] Excel Addin works that works on a template workbook
    By s.jay_k in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-15-2006, 03:35 PM
  3. [SOLVED] GetOpenFileName called from modal userform.. enables workbook windows. BUG?
    By keepITcool in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-29-2005, 10:05 AM
  4. Forms that are modal in 97 are not modal in 2003
    By Old Car in forum Excel General
    Replies: 2
    Last Post: 04-27-2005, 04:06 AM
  5. [SOLVED] Forms that are modal in 97 are not modal in 2003
    By Old Car in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-27-2005, 04:06 AM

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