+ Reply to Thread
Results 1 to 12 of 12

How to set a restriction for the content input in Inputbox

  1. #1
    Registered User
    Join Date
    08-07-2014
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    95

    Question How to set a restriction for the content input in Inputbox

    Hey, I am now using a inputbox in my macro code. But I have no idea about how I can restrict the content users input.

    My purpose is set a restriction that only allow alphabet can be input in the InputBox, such as AA,Ab,cB,dd. Any numbers, other signs and even space are not allowed.

    Thank you so much as I am a newbie in macro.

  2. #2
    Valued Forum Contributor ranman256's Avatar
    Join Date
    07-29-2012
    Location
    Kentucky
    MS-Off Ver
    Excel 2003
    Posts
    1,177

    Re: How to set a restriction for the content input in Inputbox

    You cant restrict what they type in INPUTBOX, but you can review it after...

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-07-2014
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    95

    Re: How to set a restriction for the content input in Inputbox

    Thank you very much.
    But your code is for numbers, I want alphabets...

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How to set a restriction for the content input in Inputbox

    Something like
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    08-07-2014
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    95

    Re: How to set a restriction for the content input in Inputbox

    Cool, that's what I want. But it extents to another question.
    What's the difference between "*[!A-Za-z]*" and "[!A-Za-z]"?? I tried to input @@ in the code without "*", it passed without alert. But yours code is ok.
    Thanks again.

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How to set a restriction for the content input in Inputbox

    "*[!A-Za-z]*"
    Any length of character(s) without non-alphabets.

    If you want to restrict the entry to 2 characters then
    Please Login or Register  to view this content.
    Or
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    08-07-2014
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    95

    Re: How to set a restriction for the content input in Inputbox

    I am still confused. For the code below:
    Please Login or Register  to view this content.
    I entry 111, it still can pass without error. Why?
    Thanks.

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How to set a restriction for the content input in Inputbox

    Of course.

    Your condition is targeting just one character in the inputobox.
    If it is more than one, it goes through.

    What do you want?

  9. #9
    Registered User
    Join Date
    08-07-2014
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    95

    Re: How to set a restriction for the content input in Inputbox

    Got it!!! Actually, [!A-Za-z] includes two conditions: 1,one character; 2,not alphabet。 The error alert shows only when these two conditions both are satisfied. As long as one of it is broken, it goes through. Right?

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How to set a restriction for the content input in Inputbox

    Correct and that is the difference from "*[!A-Za-z]*".

  11. #11
    Registered User
    Join Date
    08-07-2014
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    95

    Re: How to set a restriction for the content input in Inputbox

    Thank you tons!!!

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How to set a restriction for the content input in Inputbox

    You are welcome and now you can mark this thread as "Solved".

+ 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. Get input from user using application.inputbox. Input should be number and can be 0
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-11-2013, 11:28 AM
  2. [SOLVED] InputBox - If input has &, change & to ^&
    By heather1209 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-09-2012, 09:41 PM
  3. Help on date input with Inputbox
    By miaozi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-02-2011, 01:31 PM
  4. InputBox-ow to have a user input text in a inputbox
    By noodle48 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-24-2011, 08:17 AM
  5. Check on the input in an inputbox
    By Tempy in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-17-2005, 09: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