ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   code to input date after diff. cell selected (https://www.excelbanter.com/excel-programming/377897-code-input-date-after-diff-cell-selected.html)

Kelzina

code to input date after diff. cell selected
 
basically i want to insert a date in to one cell but only if i select another
cell... make sense??? i attempted the following but had no result considering
the Range("D3").... selects the cell... can anyone help
Sub Insert_Date()

If Range("D2").Select Then
cell = ("L4") = ""
Else
cell = ("L4") = "=TODAY()"
End If

End Sub
--
"The difference between Possible and Impossible is the measure of ones will"

NickHK

code to input date after diff. cell selected
 
Not sure of the logic of what you are trying to achieve, but use the
Worksheet_SelectionChange event :

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Address = Range("D2").Address Then
Range("L4").Value = ""
Else
Range("L4").Formula = "=TODAY()"
'Or
'Range("L4").Formula = Now()
End If

End Sub

NickHK

"Kelzina" wrote in message
...
basically i want to insert a date in to one cell but only if i select

another
cell... make sense??? i attempted the following but had no result

considering
the Range("D3").... selects the cell... can anyone help
Sub Insert_Date()

If Range("D2").Select Then
cell = ("L4") = ""
Else
cell = ("L4") = "=TODAY()"
End If

End Sub
--
"The difference between Possible and Impossible is the measure of ones

will"



Kelzina

code to input date after diff. cell selected
 
nevermind, my explanation is prolly to confusing, ill try something else,
thanx anyway
--
"The difference between Possible and Impossible is the measure of ones will"


"NickHK" wrote:

Not sure of the logic of what you are trying to achieve, but use the
Worksheet_SelectionChange event :

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Address = Range("D2").Address Then
Range("L4").Value = ""
Else
Range("L4").Formula = "=TODAY()"
'Or
'Range("L4").Formula = Now()
End If

End Sub

NickHK

"Kelzina" wrote in message
...
basically i want to insert a date in to one cell but only if i select

another
cell... make sense??? i attempted the following but had no result

considering
the Range("D3").... selects the cell... can anyone help
Sub Insert_Date()

If Range("D2").Select Then
cell = ("L4") = ""
Else
cell = ("L4") = "=TODAY()"
End If

End Sub
--
"The difference between Possible and Impossible is the measure of ones

will"





All times are GMT +1. The time now is 08:33 AM.

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