+ Reply to Thread
Results 1 to 6 of 6

Input box...

  1. #1
    Registered User
    Join Date
    02-16-2010
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    16

    Input box...

    I need a code for input box asking "Please enter Business Unit".
    It should except only 4 digits which should be numeric. Should not accept text or less or more than 4 digits. If tried to enter should give an error.
    It should accept only these business units - 0513, 0517, 0527, 2155, 2159, 2127, 3654 & 3655.
    If user try to input any other thing apart from the above business units it should show error as "INVALID ENTRY".
    The inputted data should get stored in sheet named "Control Sheet" in "C3"

    Second input box should be asking for "Please enter date in mm-dd-yyyy format"
    if the input is not in this format it should give an error "INVALID ENTRY".
    If properly inputted the same should get stored in sheet named"Control Sheet" in "K3"

    Kindly Help

    --
    Thanks,

    Mayank

  2. #2
    Valued Forum Contributor tony h's Avatar
    Join Date
    03-14-2005
    Location
    England: London and Lincolnshire
    Posts
    1,187

    Re: Input box...

    Hi,
    did you realise tha you can do this on the spreadsheet without code? You can use the Data Validation (Data tab ... data vlidation) on the cell.

    for the first item use List and then either have a list on the spreadsheet or put in the values seperated by commas. For the second item use Date.

    Hope this helps


    click on the * Add Reputation if this was useful or entertaining.

  3. #3
    Registered User
    Join Date
    02-16-2010
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Input box...

    Hi Tony....

    My requirement is just a small part of my whole macro which is almost ready. Though you are right in saying that it can be done through data validation, but I need this do be done through a macro, as this would be a part of my whole macro to be done in a single click.

    Thanks
    Mayank

  4. #4
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Input box...

    Hi,
    have you thinked about using userform with a combo box for the business units and a textbox for the date?

    Buran
    If you are pleased with a member's answer then use the Star icon to rate it.

  5. #5
    Registered User
    Join Date
    02-16-2010
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Input box...

    Hi Buran,
    Definately I would be using userform for the same. But I need a macro to link that userform button with macro which will perform the above activity.

    Thanks.
    Mayank

  6. #6
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Input box...

    If you are using user form as I suggested, then you can add to the combo box only these unit numbers that you want and prevent user from entering something different (MatchRequired Property). So you don't have to check this.
    Regarding the date, you can use for example exit event to check if entry is a valid date:
    Please Login or Register  to view this content.
    Of course, your form will have at least two Command Buttons - OK and Cancel and you will set Enable property of the OK button to false and change it to True only when both the combobox and text box entries are valid.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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