MS Excel: Automatically select from drop down list based on date

I have two columns. In A1 I have a date. In B1 I have the status of a project (Pending, Active, On Hold, Closed, Expired) that is part of a drop down list. Is there a way to have B1 automatically select a status based on the date is is entered in A1? I am really only interested in B1 being selected as "Expired" automatically when a certain date has passed. Otherwise, I want the user to be able to select any of the other choices. However, selecting "Closed" will ignore the date altogether and not change the status to "Expired".
karitheAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ejgil HedegaardCommented:
Insert this in the worksheet module.

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("A1:B1")) Is Nothing Then
        Application.EnableEvents = False
        If Range("B1") <> "Closed" Then
            If Range("A1") > Now Then
                Range("B1") = "Expired"
            End If
        End If
        Application.EnableEvents = True
    End If
End Sub

Open in new window


The date check specification is set to actual day (Now)
Change to what you need
Datavalidation-check-and-fill.xlsm
1
karitheAuthor Commented:
Ejgil Hedegaard,

excellent solution. how do i get it to work down the rest of the column?
0
Ejgil HedegaardCommented:
Replace the code with this, and copy B1 down to get the validation on the cells.

Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("A:B")) Is Nothing Then
        Application.EnableEvents = False
        If Range("B" & Target.Row) <> "Closed" Then
            If Range("A" & Target.Row) > Now Then
                Range("B" & Target.Row) = "Expired"
            End If
        End If
        Application.EnableEvents = True
    End If
End Sub

Open in new window

1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.