?
Solved

How to validate the column in excel sheet.

Posted on 2012-09-15
3
Medium Priority
?
408 Views
Last Modified: 2012-10-03
I have an excel sheet where in I want the column A to be validated for following conditions.
1.It should accept only dates.
2.In order dd-mmm-yy ex: 5-Jan-12
3.Other than this should make the cell red.
4. The cell may be emoty.
5. But if the cell has values it should support this format only.
0
Comment
Question by:searchsanjaysharma
3 Comments
 
LVL 27

Expert Comment

by:skullnobrains
ID: 38401503
- apply the date format you want to the column. this will make most errors visible to the user as mistyped dates will appear invalid or mapped to a different date
- use conditional formatting (available from the context menu relative to the cell) to make the bad cells red. check for a reasonable time range using DATEDIF()

---

if you need the column to be a string, you can validate a date by building an excel date from the provided string using DATE() and various string functions, and then reformat the date as a string and check that both strings are identical. in this way, you let excel chack for valid dates in terms of number of days per month, 29th octoberts and such stuff
0
 
LVL 10

Accepted Solution

by:
mark_harris231 earned 1500 total points
ID: 38401843
Assuming your primary goal is to prevent non-dates/invalid dates, I'd recommend using Data Validation (on the Data tab) and date formatting, rather than trying to flag bad data.  "An ounce of prevention" and all that. See attached example.

Note that other date formats can be entered (e.g., 9/15/2012), but will be converted to the desired format.  I set a Start Date of 9/15/2012 and an End Date of 12/31/2050, but these (and the input/error messaging) can be edited to whatever is appropriate.

---
+1 to skull's discussion on string/date discussion
ValidatedDate.xlsx
0
 

Author Closing Comment

by:searchsanjaysharma
ID: 38457950
ok
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

612 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