[USER="31712"]Carim[/USER] I got it to work part way on your sample. The year does change, but it won't accept the day change. it is currently showing 10/11/2019. When i change the 11 to 15, & the curser is in the cell, it accepts it. Once the curser is moved it goes back to 101/11/2019. Any ideas? I typed 10/1//20000 in a different cell & copied it to G19, it would accept the change in the new cell, but not G19. I wonder if there is something in the code, that is causing the problem.
Sadly I am not able to replicate the situation you are describing ...
Very sorry ... but cannot be of further assistance ...
At my end .... everything does function as expected ...
Hope you will manage to sort it out ...
[USER="31712"]Carim[/USER] The year does change, but it won't accept the day change. it is currently showing 10/11/2019. When I change the 11 to 15, & the curser is in the cell, it accepts it. Once the curser is moved it goes back to 101/11/2019. Do you have any idea why it won' accept the day change? I have included a sample ( Test Sample Vet V3.2.xlsm).
Sorry ... but just carried out a few tests in your latest sample file ...
And everything is fine ... :rock:
Thanks. That is weird. It works on your end, but not mine.
As already indicated in message # 34 ... you do need to :Quote
Make sure your Excel > Options > Formulas > Workbook Calculation : Set to Automatic ...
[USER="31712"]Carim[/USER] Got it working. I played around with it, & I did not need those 2 cells that we had for the month & year. I did learn that I had to place it at the beginning of all the code. Here is the working code:Code
- Option Explicit
- Private Sub Worksheet_Change(ByVal Target As Range)
- 'Changes year to current year.
- 'This line unlocks the sheet.
- 'ActiveSheet.Unprotect "Real Password"
- Dim switchAddress As Variant
- switchAddress = "AW1"
- If Target.Address = "$F$19" And Range(switchAddress) <> 1 Then
- Range(switchAddress) = 1
- Target = Month(Target) & "/" & Day(Target) & "/" & Year(ActiveSheet.Range("F20"))
- If Target <= Target.Offset(1, 0) Then
- MsgBox " Can't Schedule in Past!! "
- End If
- Range("F22") = DateDiff("d", Target.Offset(1, 0), Target)
- 'ActiveSheet.Protect "Real Password", True, True
- End If
- End Sub
I wanted to thank you for your assistance & educational instruction, that you provided.
Glad you have managed to sort it out ...:smile:
Thanks for your Thanks