+ Reply to Thread
Results 1 to 14 of 14

Need help to setup restriction (countries) on an already existed VBA

  1. #1
    Registered User
    Join Date
    08-04-2008
    Location
    Los Angeles, CA
    Posts
    33

    Need help to setup restriction (countries) on an already existed VBA

    Hi,

    I recently got a project to enhance a new field to restrict some countries from an invoice. For setting up restriction for certain matters, is it better to set a table and list out all of the countries that I want to include, and the one that is left out, then I want to restrict them?

    I don't have the data with me because the data will be extracted out from another database that I don't have access to. My role is only to put a restriction tool in the form so when the data entry people run the form, it can restrict them from entering data from the countries that is restricted by the company.

    The restriction data I am planning to have is listed like below, please teach me how I can have the code look up to the worksheet placed on the desktop (later on I will put this file on the share folder with the vba and form). what I want to do is to put a restriction warning if the data entry person enter an restriction country, then it will not help them process the invoice into the database. Please advice.
    Attached Files Attached Files
    Last edited by siulonbow; 09-29-2010 at 11:50 AM.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Need help to setup restriction (countries) on an already existed VBA

    If you use Data Validation with a drop down list and all valid countries, it will give a warning and not allow you to enter what is not on the list. You don't need VBA or a UserForm for this process.

    If you already have a Userform and using VBA then you can test for these in your code. If they are found on the userform you would pop up a nasty message and erase the value from the textbox.

    There are most likely many ways to accomplish your task. It all depends on what your spreadsheet looks like and how involved you want to get with the data or code.

  3. #3
    Registered User
    Join Date
    08-04-2008
    Location
    Los Angeles, CA
    Posts
    33

    Re: Need help to setup restriction (countries) on an already existed VBA

    "If you already have a Userform and using VBA then you can test for these in your code. If they are found on the userform you would pop up a nasty message and erase the value from the textbox."

    I think this is what I want to do. I want to code to erase all information entered into the sheet and give a nasty message saying "country entered is restricted". I need to implement this command into the already existed userform. Can you please show me what would be the code that can connect to the excel file restricted list and to the form? I tried to search on Google for the whole day, but I can't find any return. Thanks

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Need help to setup restriction (countries) on an already existed VBA

    The answer is in being able to write a little VBA code. It comes down to a few "IF" statements and a "MSGBOX" or two.
    Without seeing your work or Userform it is hard to give more specific instructions than the above.

    I find by searching the net some Userform Code Examples at http://www.ozgrid.com/VBA/UserForms.htm
    These are the fundamental building blocks of what your are attempting.

  5. #5
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Need help to setup restriction (countries) on an already existed VBA

    Hi siulonbow

    I've posted a rudimentary example of how you can do this. Enter a Restricted Country into the Textbox and press enter or tab out of the Textbox. See if you can work the example into your code.

    John
    Attached Files Attached Files
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  6. #6
    Registered User
    Join Date
    08-04-2008
    Location
    Los Angeles, CA
    Posts
    33

    Re: Need help to setup restriction (countries) on an already existed VBA

    I have attached the screen shot, and I would like to add a dropbox to list out the country included. Are there anyway I can have a list of un-restricted countries? Please demonstrate. Thanks

    Later on, I would want to add a date field that will automatically send out a reminder email to the customer saying it's time to make a payment.
    Attached Files Attached Files

  7. #7
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Need help to setup restriction (countries) on an already existed VBA

    Hi siulonbow

    The attached demonstrates
    Are there anyway I can have a list of un-restricted countries?
    John
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    08-04-2008
    Location
    Los Angeles, CA
    Posts
    33

    Re: Need help to setup restriction (countries) on an already existed VBA

    Hi Jaslake,

    I kind of have an idea of what you mean. I have 2 questions.

    1) How can I tell the user form the location?
    2) Is the code going to restrict everything listed in the worksheet? and should I use a dropbox that have all countries selection. In that case, the processor will not be able to enter any other invalid countries into the system. If taking dropbox route, what should I do?

    Thanks for your time again.
    S.

  9. #9
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Need help to setup restriction (countries) on an already existed VBA

    Hi siulonbow

    Regarding your questions:
    How can I tell the user form the location
    I don't really understand the question. The location of what? Where to put the UserForm? How to populate the UserForm? Please expand your inquiry.
    Is the code going to restrict everything listed in the worksheet?
    The code will do what you tell it to do. The code I've provided doesn't to anything. It's merely a demonstration of this
    Are there anyway I can have a list of un-restricted countries? Please demonstrate.
    should I use a dropbox that have all countries selection
    I don't know. How many Unrestricted Countries are there? How many Restricted Countries are there? If you have a dropdown list of 500 countries, that's too much information.
    If taking dropbox route, what should I do
    Again, I don't know. I have no idea what your process is or how all of this integrates. You need to detail your current process (and share dummy data) and explain how you wish to change the current process. At this point, I can't (and won't) even begin to guess what you're after. I need MUCH more information.

    I'll be glad to help if I can. I need a place to start. Only you can provide that.

    John

  10. #10
    Registered User
    Join Date
    08-04-2008
    Location
    Los Angeles, CA
    Posts
    33

    Re: Need help to setup restriction (countries) on an already existed VBA

    So sorry John, I don't mean to be lacking a lot of information to my questions. I will try to be more elaborate.

    I have tried to zip the file and attached in this thread. I hope this will find you well.

    I am planning to implement 2 new command into the current userform.

    1) this will be a dropbox that list out all countries that is not restricted. I want to have this drop box lookup to a list at a sharefolder. Let say it's at the desktop. If the user can't find the country, then it's a restricted one. hence, he shouldn't process the invoice.

    2) I also want to add a email reminder data into this form. The reminder is to the customer. The processor sometime forgot to send out a reminder mail to the customer, so the manager want to add this option so the processor doesn't have to do that. I want to have a drop box of date. when the date come, a reminder email with text will send out to the customer through outlook. It is very similar to the Send Email command that is currently on the userform.

    I hope this will help with a more thorough questions, please let me know if this help.
    Attached Files Attached Files

  11. #11
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Need help to setup restriction (countries) on an already existed VBA

    Hi siulonbow
    When I unzip your file it creates a file called TB1.sln. I don't know what that is but I can't open it.
    John

  12. #12
    Registered User
    Join Date
    08-04-2008
    Location
    Los Angeles, CA
    Posts
    33

    Re: Need help to setup restriction (countries) on an already existed VBA

    I was using a MS VB express, I don't know if it's causing this problem. How should I go about the resolve this? Sorry to bring this problem up.

  13. #13
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Need help to setup restriction (countries) on an already existed VBA

    Hi siulonbow

    I'm not familiar with MS VB express. What version of Office are you using (I'd suggest you update your profile to include this information)?

    Office 2007 has a built in zip procedure. Right Click the file ->Send To-> Compressed (zipped) Folder.

    Beyond that, there are many free Zip programs available on the Web.

    John

    PS: I guess I should have asked if your file is too large to send as an Excel file
    Last edited by jaslake; 09-29-2010 at 05:24 PM.

  14. #14
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Need help to setup restriction (countries) on an already existed VBA

    Your post does not comply with Rule 8 of our Forum RULES. Cross-posting is when you post the same question in other forums on the web. You'll find people are disinclined to respond to cross-posts because they may be wasting their time solving a problem that has been solved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser)to the cross-post. Expect cross-posts without a link to be closed a message will be posted by the moderator explaining why. We are here to help so help us help you!

    Read this to understand why we ask you to do this
    Remember what the dormouse said
    Feed your head

+ 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