RogueRoustabout
New Member
- Joined
- Mar 11, 2024
- Messages
- 3
- Office Version
- 365
- Platform
- Windows
In simple terms here is the macro I want to write:
- When "Sheet1" is activated,
- If the date in "Range1" is current, end macro
- If the date in "Range1" is not current,
- Prompt the user to update (Msg box "do you want to update the date? yes/no")
- If user clicks "no" - end macro
- If user clicks "Yes" - update "Range1" with current date.
Below is the code that I tried to put together, but I am missing something.
Thank you for any help!
- When "Sheet1" is activated,
- If the date in "Range1" is current, end macro
- If the date in "Range1" is not current,
- Prompt the user to update (Msg box "do you want to update the date? yes/no")
- If user clicks "no" - end macro
- If user clicks "Yes" - update "Range1" with current date.
Below is the code that I tried to put together, but I am missing something.
VBA Code:
Private Sub Worksheet_Activate()
Range("N15:R15").Select
If Range("N15:R15").Value = Today Then
Exit Sub
End If
response = MsgBox("Would you like to set the date to today?", vbYesNo)
If response = vbNo Then
MsgBox ("Macro Ending")
Exit Sub
End If
Range("N15:R15").Select
ActiveCell.FormulaR1C1 = Now
End Sub
Thank you for any help!