+ Reply to Thread
Results 1 to 5 of 5

How to open msgBox and close UserForm if no data found

  1. #1
    Forum Contributor
    Join Date
    08-14-2012
    Location
    USA
    MS-Off Ver
    Excel 2007, MS 365 (Windows 10 Pro 64-bit)
    Posts
    810

    How to open msgBox and close UserForm if no data found

    Hi all,
    I'm trying to open the workbook base on Cell value and I would like to open MsgBox and close UserForm if the file does not exsit.

    Regards,
    tt3
    Please Login or Register  to view this content.
    Last edited by tuongtu3; 12-11-2012 at 03:44 PM. Reason: SOLVED

  2. #2
    Forum Contributor
    Join Date
    08-14-2012
    Location
    USA
    MS-Off Ver
    Excel 2007, MS 365 (Windows 10 Pro 64-bit)
    Posts
    810

    Re: How to open msgBox and close UserForm if no data found

    Hi all,
    Any help with this code please. The code is not correct but I posted there just for more details to show what I need.

    I have UserForm with TextBox2
    1. If TextBox is empty then show msgBox "Please enter Vehicle info" and exit UserForm.

    2. If TextBox has entered with value then searching the file in drive "Y:\Testing\"
    a_ Open the WorkBook if file name is valid and exit UserForm.
    b_ Or Show msgBox "File not found" if file name is invalid and exit UserForm.

    Regards,
    tt3
    Last edited by tuongtu3; 12-11-2012 at 02:22 AM. Reason: Spelling

  3. #3
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: How to open msgBox and close UserForm if no data found

    See attached file where I used this macro:
    Please Login or Register  to view this content.
    Regards,
    Antonio
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    08-14-2012
    Location
    USA
    MS-Off Ver
    Excel 2007, MS 365 (Windows 10 Pro 64-bit)
    Posts
    810

    Re: How to open msgBox and close UserForm if no data found

    Hi Antonio,
    The code works on the sample and my worksheet too. Thank you very much for your time and help.
    Can you explain why the code have 2 * at ".*xls*") and 1 * at ".xls*")? Does it work as same as without *?

    Regards,
    tt3

  5. #5
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: How to open msgBox and close UserForm if no data found

    I used jolly chars because excel can have extensions .xls or .xlsm or other... probably I was wrong to use first asterisk, I could use ".xls*".
    Regards,
    Antonio

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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