convert yes to date

jvlavl

New Member
Joined
Nov 27, 2017
Messages
15
Hello,

I'm looking for a way to convert the YES input to the today date

for example A3 is filled with Yes on Sheet1 sheet2 A4 should be filled with the Date of today.

Is there a way to do this?

If yes could you help me on the way?

Thanks in advance

Rgds,

John
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Will you always only be working with A3 in Sheet1 and A4 in Sheet2?
 
Upvote 0
Make sure that A4 in Sheet2 is formatted as "Date" and then copy/paste this formula in A4: =IF(Sheet1!A3="Yes",NOW(),"")
 
Upvote 0
Hello,

Thanks for answer, but I how do I include this in a Macro that runs when the file is closed?

Rgds,

John
 
Upvote 0
Place this macro in the code module for ThisWorkbook. Do the following: Hold down the ALT key and press the F11 key. This will open the Visual Basic Editor. In the left hand pane, double click on "ThisWorkbook". Copy/paste the macro into the empty window that opens up. Close the window to return to your sheet. When you close the workbook, the macro will run automatically.
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
    If Sheets("Sheet1").Range("A3") = "Yes" Then
        Sheets("Sheet1").Range("A3") = Date
    End If
End Sub
If you also want the macro to run when you save the workbook, add this macro to the same code module.
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    If Sheets("Sheet1").Range("A3") = "Yes" Then
        Sheets("Sheet1").Range("A3") = Date
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top