This is a basic approach using the change event:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngDU As Range, rngDV As Range
If Target.Count > 1 Then Exit Sub
If IsEmpty(Target) Then Exit Sub
If Target.Column = 4 And Target.Row > 1 Then
Set rngDU = Cells(Target.Row, "DU")
Set rngDV = Cells(Target.Row, "DV")
Select Case True
Case Target = 11 And IsEmpty(rngDU)
Case Target <> 12 And Not IsEmpty(rngDU)
End Select
End If
End Sub
You know your conditions better than I do. You can continue with the select
case paradigm or revert to an If - Then - Else structure. Work the logic
you know into the procedure and post back if you have a specific question.
You would right click on the sheet tab and select view code, then enter you
code there. (You can select the change event from the dropdowns at the top
of the module Worksheet in the left, Change in the right).
http://www.cpearson.com/excel/events.htm
--
Regards,
Tom Ogilvy
"Bob" wrote:
> I have a worksheet containing project-related information. In particular:
>
> Column D = Status Code (0 - 20); Code "11" = On-Hold, Code "12" = Cancelled
> Column DT = Project Hold Date
> Column DU = Project Un-Hold Date
> Column DV = Project Cancelled Date
> Column DW = Project Un-Cancelled Date
>
> I'm trying to write a macro whereby if a user inputs Code "11" in Column D
> for a given project, the current date would automatically be entered in
> Column DT. Later on, if the Code is changed to anything but Code 11 (except
> for Code 12), the current date would automatically be entered into Column DU.
>
> If a user inputs Code "12" in Column D for a given project, the current date
> would automatically be entered in Column DV. Later on, if the Code is
> changed to anything but Code 12 (except for Code 11), the current date would
> automatically be entered into Column DW.
>
> Also, it would be nice if the macro displayed an error message if a user
> attempts to indicate that a project is on Hold or Cancelled more than once
> (i.e., check to see if columns DT - DW already contain a date).
>
> Any help would be greatly appreciated.
> Thanks,
> Bob
>