Hi everyone, I was hoping to get some help with a spreadsheet I am creating for work. I have had this partly answered on here but theres a slight issue with it that I hope someone knows the solution to.
I have a spreadsheet with a "Yes" "No" drop down boxes set up in column G. These run down the column to row 16. What I want is for the date that the drop down box is changed to "Yes" to be entered in the cell to the right of that box. So, if the drop down box in cell G2 is changed to "Yes" today (21/02/11) the cell to the right (H2) will enter the date of when that work was completed. I have the code for this working and set up in VBA. It looks like this:
The only problem is when I try to change the "Yes" back to "No". When I do this the date stays as it was in the cell next to it. So if a mistake is made and the wrong cell is changed back to "No" the date remains. Does anyone know how I can make the cell to the right of the drop down blank again if it is changed back?
Any help with this will be greatly appreciated.
I have a spreadsheet with a "Yes" "No" drop down boxes set up in column G. These run down the column to row 16. What I want is for the date that the drop down box is changed to "Yes" to be entered in the cell to the right of that box. So, if the drop down box in cell G2 is changed to "Yes" today (21/02/11) the cell to the right (H2) will enter the date of when that work was completed. I have the code for this working and set up in VBA. It looks like this:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 7 And LCase(Target.Value) = "yes" Then
Application.EnableEvents = False
Target.Offset(, 1).Value = Date
Application.EnableEvents = True
End If
End Sub
The only problem is when I try to change the "Yes" back to "No". When I do this the date stays as it was in the cell next to it. So if a mistake is made and the wrong cell is changed back to "No" the date remains. Does anyone know how I can make the cell to the right of the drop down blank again if it is changed back?
Any help with this will be greatly appreciated.