Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Excel InputBox to accept text / letters only

Posted on 2013-01-24
6
Medium Priority
?
781 Views
Last Modified: 2013-01-29
Hello Experts,

So simple enough question that I cannot figure out or find an answer for.  In my VBA script for excel I am trying to create an input box that only accepts letters. Basically the user has to put in a persons name. No numbers, no other special characters, white space is allowed.

Can anyone show me how to do this?
0
Comment
Question by:thomashospital
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 19

Expert Comment

by:helpfinder
ID: 38813952
sorry maybe offtopic, but if it is only about person´s name and the names are known you can use Data validation feature in Excel, so you just create list of persons and users can only pick one of them.
so if you have a list and do not need VBA for some special reason this is alternative for you
sample
0
 

Author Comment

by:thomashospital
ID: 38813969
I will definitely will keep that in mind for future reference helpfinder, but in this instance they need to populate that box.
0
 
LVL 52

Expert Comment

by:Rgonzo1971
ID: 38813989
Hi,

You could refer to

http://vbcity.com/forums/t/148339.aspx

Regards
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 19

Assisted Solution

by:helpfinder
helpfinder earned 2000 total points
ID: 38814010
Or again me and again without VBA :)
just found the formula which accepts only text characters if you put it as custom in Data validation

=AND(MIN(CODE(MID(UPPER(A1);ROW(INDIRECT("1:"&LEN(A1)));1)))>65;MAX(CODE(MID(UPPER(A1);ROW(INDIRECT("1:"&LEN(A1)));1)))< 90)

Open in new window


and now I promise I won´t reply to this threat non VBA post anymore :)
0
 

Accepted Solution

by:
thomashospital earned 0 total points
ID: 38815077
Ultimately I just figured it out.  I will post it here for the simple fact that I have searched end over end and could not find a solution to it.  Now this is not the cleanest code so feel free for anyone that uses it to clean it up.  To give credit a piece of this was taken from Mr.Excel.com

Range("d3") = InputBox("Copy over patient info")
    If Asc(Range("d3")) > 64 And Asc(Range("d3")) < 91 Then
    ElseIf Asc(Range("d3")) > 96 And Asc(Range("d3")) < 123 Then
       Else
        Do
            MsgBox "Invalid entry"
            Call AscTest
            Loop Until Asc(Range("d3")) > 64 And Asc(Range("d3")) < 91 Or Asc(Range("d3")) > 96 And Asc(Range("d3")) < 123
    End If

End Sub

Sub AscTest()
Range("d3") = InputBox("Copy over patient info")
    If Asc(Range("d3")) > 64 And Asc(Range("d3")) < 91 Then
        
    ElseIf Asc(Range("d3")) > 96 And Asc(Range("d3")) < 123 Then
        
    Else
        MsgBox "Invalid entry"
    End If
End Sub

Open in new window

0
 

Author Closing Comment

by:thomashospital
ID: 38830313
Thanks for all the help and feedback!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Outlook for dependable use in a very small business   This article is about using the Outlook application (part of Microsoft Office) in a very small business, or for homeowners where dependability and reliability are critical requirements. This …
Cancel future meetings from user mailboxes in Office 365 using Remove-CalendarEvents
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question