ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Create a date that will not change (https://www.excelbanter.com/excel-programming/379999-create-date-will-not-change.html)

[email protected]

Create a date that will not change
 
If a cell returns a certain value, can a date be made to appear in an
adjacent cell that will not change even if the first cell's value does
change with time. For example, if cell A1=1, then B1 shows the date
A1=1, even though A1 will eventually excede the value of 1 (therefore
A1=1). I need a date macro that will show only the first date A1=0.
Thanks.


Gary''s Student

Create a date that will not change
 
The macro in Worksheet code:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("A1").Value = 1 And Range("B1").Value = "" Then
Range("B1").Value = Format(Now, "mm/dd/yyyy")
End If
End Sub

waits until A1 = 1 It then sets the current date in B1.

Once a date has been entered in B1 the macro will not change it.
--
Gary's Student


" wrote:

If a cell returns a certain value, can a date be made to appear in an
adjacent cell that will not change even if the first cell's value does
change with time. For example, if cell A1=1, then B1 shows the date
A1=1, even though A1 will eventually excede the value of 1 (therefore
A1=1). I need a date macro that will show only the first date A1=0.
Thanks.



[email protected]

Create a date that will not change
 
Thanks so much for the Christmas present. It works as expected.

Michael

Gary''s Student wrote:
The macro in Worksheet code:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("A1").Value = 1 And Range("B1").Value = "" Then
Range("B1").Value = Format(Now, "mm/dd/yyyy")
End If
End Sub

waits until A1 = 1 It then sets the current date in B1.

Once a date has been entered in B1 the macro will not change it.
--
Gary's Student


" wrote:

If a cell returns a certain value, can a date be made to appear in an
adjacent cell that will not change even if the first cell's value does
change with time. For example, if cell A1=1, then B1 shows the date
A1=1, even though A1 will eventually excede the value of 1 (therefore
A1=1). I need a date macro that will show only the first date A1=0.
Thanks.





All times are GMT +1. The time now is 12:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com