now() just one time

P

puiuluipui

Hi, i need a small code with now().

When i write some text in A1, the time to appear in B1. But i need the time
to appear just once. If i close the workbook and open it again, the time to
remin intact. I want the code to work just once. And olso, if i add something
in A1 the code to remain intact.
If the first time i write something in A1 the time will be 12:00, then this
time to remain displayed all the time.
can this be done?
Thanks in advance.
 
S

Stefi

I think you meant CNTRL-SHFT-:
(colon instead of semicolon)

Regards,
Stefi


„Gary''s Student†ezt írta:
 
S

Stefi

Now I see the point: it depends on the keyboard used. On my keyboard
(Hungarian) there is fullstop under colon, semicolon is on another key in
AltGr combination.
Stefi


„Gary''s Student†ezt írta:
 
P

puiuluipui

Hi,
i need something more like:
=if A1""(B1(CNTRL-SHFT-;)) or something like this. The code to be activated
when i write something in A1 and to work only one time, and the result to
remain the same.


A B
1 gsp 12:30
2 bgr 12:45
3

If A3 is empty, B3 to be empty as well.
Thanks in advance.
 
G

Gord Dibben

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'when entering data in a cell in Col A
On Error GoTo enditall
Application.EnableEvents = False
If Target.Cells.Column = 1 Then
N = Target.Row
If Me.Range("A" & N).Value <> "" Then
Me.Range("B" & N).Value = Now
End If
End If
enditall:
Application.EnableEvents = True
End Sub

This is sheet event code. Right-click on the sheet tab and "View Code"

Copy/paste the code into that module.

Alt + q to return to the Excel window.


Gord Dibben MS Excel MVP
 
P

puiuluipui

Hi, it's working, but if i add someting in cell A1 or another cell in column
A, the time its changing. Sometimes i have to change the text in some cell
or to add something, but i don't want the time to be changed. I need the
first "time" that code generated.
Thank you so much.





"Gord Dibben" a scris:
 
P

puiuluipui

Hi, is there a way to make your code start from "A5" ?

Thanks!

"Gord Dibben" a scris:
 
Top