retain date

Trevor3007

Well-known Member
Joined
Jan 26, 2017
Messages
675
Office Version
  1. 365
Platform
  1. Windows
Hi,

I use the the code below:-
=IF(G2="y",TEXT(TODAY(),"dd/mm/yyyy"),"")

which work great until the next day, when yesterdays day is now the present day. Is there a way to retain the original date ?

Many thanks in advance.

KR
Trevor3007
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
thanks for your swift reply & assistance thereof...

I had a look and yes there is plenty but I am unsure which to choose & politely request if you could choose the best & supply the applicable code?

Many thanks
Trevor3007
 
Upvote 0
This is normally done with vba code. Would that be acceptable?
If so, does G2 have a formula that might return "y" or is G2 entered manually?
If a formula, what is the formula in G2?
What column do you want the date in?
 
Upvote 0
Hi Perter_SSs,

=IF(G2="y",TEXT(TODAY(),"dd/mm/yyyy"),"") is in B2 . The =IF(G2="y",TEXT(TODAY(),"dd/mm/yyyy"),"") in the 2 worksheet. This particular worksheet tab changes its name weekly so I hope this wont by an issue?

thanks again

thank you for your time
 
Upvote 0
OK, so it seems that you want the date in column B.
What about my other questions?
This is normally done with vba code. Would that be acceptable?
If so, does G2 have a formula that might return "y" or is G2 entered manually?
If a formula, what is the formula in G2?
 
Upvote 0
DOH...sorry I had doen so.

when Y is manually placed into G2, B2 then puts in the date....

Hope this has now given you sufficient info :}
 
Upvote 0
ooops...spelling error in previous detected!!


OH...sorry thought I had already explained .....

 
Upvote 0
Try this Worksheet_Change code in a copy of your workbook. To implement ..
1. Right click the sheet name tab and choose "View Code".
2. Copy and Paste the code below into the main right hand pane that opens at step 1.
3. Close the Visual Basic window & test.
4. Your workbook will need to be saved as a macro-enabled workbook (*.xlsm).

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim Changed As Range, c As Range
  
  Set Changed = Intersect(Target, Columns("G"), Rows("2:" & Rows.Count))
  If Not Changed Is Nothing Then
    Application.EnableEvents = False
    For Each c In Changed
      If LCase(c.Value) = "y" Then Range("B" & c.Row).Value = Format(Date, "dd/mm/yyyy")
    Next c
    Application.EnableEvents = True
  End If
End Sub
 
Upvote 0
many thanks...

2 isues
1 = date returns 8/7/2018 as opposed to 7/8/2018
2 = when cell b2 has y in shows date, but if you remove the y , the date remains

sorry for the bother.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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