Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Yes or No

Posted on 2011-03-04
3
Medium Priority
?
789 Views
Last Modified: 2012-05-11
Experts,
I've looked at data validation and it is not getting me what I need.

In my spreadsheet from H12:H22 the user can only type in a yes or a no. Anything else is not allowed. The yes and no needs to be capitlaized regardless of how the user enters it. I've looked at the Workbook_Change event.
0
Comment
Question by:Frank Freese
[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 Comments
 
LVL 12

Assisted Solution

by:sdwalker
sdwalker earned 800 total points
ID: 35037997
Data Validation DID work for me.  Select to Allow a list and for the Source, type in "YES,NO" (without the quotes).

It restricts the answers to capital YES and NO.
0
 
LVL 39

Accepted Solution

by:
nutsch earned 1200 total points
ID: 35037998
Hi, this code should do it:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim cl As Range

Application.EnableEvents = False
If Not Intersect(Target, Range("H12:H22")) Is Nothing Then
    For Each cl In Intersect(Target, Range("H12:H22")).Cells
        If UCase(cl) <> "YES" And UCase(cl) <> "NO" Then
            cl.ClearContents
        Else
            cl = UCase(cl)
        End If
    Next
End If
Application.EnableEvents = True
End Sub

Open in new window


Thomas
0
 
LVL 6

Expert Comment

by:FernandoFernandes
ID: 35038135
sdwalker's suggestion is indeed the cleanest, and works as you want...
but as far as I understand, the user is somehow supposed to be able to enter "yes", butyou want this to be converted to "YES", right ?
in this case, nutsch solution is the most appropriate... but it will put VBA in your file... means, you get what you want, but as a "gift" you'll always have to enable macros...
0

Featured Post

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.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

610 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