Jump to content

automatic time stamp in excel


zico martin
 Share

Recommended Posts

I know there's a few excel experts in here so Im hoping someone can help me set this up ( and explain how in laymens terms of course!).

 

What I require is that when I add a value to a cell in column B that the time and date are automatically added to the adjacent cell in column A. Ideally this will then not be changed when I amend any details in any of the cells on that row. I've had a quick look on the net and though it appears it can be done I really cant fathom how to go about it :D

 

thanks in advance?

Link to comment
Share on other sites

The syntax for the current date and time to be stamped into a cell is

=now()

 

All you will have to do I'm guessing is build an IF clause on the basis of that. i.e. if the cell in column B changes, then =now() is applied to the corresponding cell in column A.

 

If I get chance later, I'll try and knock up an example.

Link to comment
Share on other sites

The syntax for the current date and time to be stamped into a cell is
=now()

 

All you will have to do I'm guessing is build an IF clause on the basis of that. i.e. if the cell in column B changes, then =now() is applied to the corresponding cell in column A.

 

If I get chance later, I'll try and knock up an example.

 

thanks I'd appreciate that

Link to comment
Share on other sites

If you're okay with the date/time stamp updating whenever you update the values in column B then this'll do the job

=IF(B1="","",NOW())

 

You'll also need for format column A to be the date/time format you require.

Link to comment
Share on other sites

If you're okay with the date/time stamp updating whenever you update the values in column B then this'll do the job

=IF(B1="","",NOW())

 

You'll also need for format column A to be the date/time format you require.

 

 

thanks but i cant get that working for me. I insert this formula into the relevant cell but it appears to enter the date/ time whether there is a value in column B or not. Also for this to be of any use it would need to be fixed and not change when any of the values in the row are altered. Sorry to be a nag.

Link to comment
Share on other sites

I believe that this Subroutine will do what you want

 

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Cell As Range
For Each Cell In Target
With Cell
If .Column = Range("B:B").Column Then
Cells(.Row, "A").Value = Int(Now)
End If
End With
Next Cell
End Sub

Link to comment
Share on other sites

I believe that this Subroutine will do what you want

 

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Cell As Range
For Each Cell In Target
With Cell
If .Column = Range("B:B").Column Then
Cells(.Row, "A").Value = Int(Now)
End If
End With
Next Cell
End Sub

 

 

cool

 

 

so where do i put it? what do i do with it? :rolleyes:

Link to comment
Share on other sites

I believe that this Subroutine will do what you want

 

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Cell As Range
For Each Cell In Target
With Cell
If .Column = Range("B:B").Column Then
Cells(.Row, "A").Value = Int(Now)
End If
End With
Next Cell
End Sub

 

 

cool

 

 

so where do i put it? what do i do with it? :rolleyes:

 

I havent got Excel to hand but I believe that if you go into Tools>Macros>Visual Basic Editor then you'll get two panes, the left hand side has a sort of navigation tree, click on the worksheet you're wanting to do it on and cthe right hand pane will go clear. Paste it in there to attach it to that Workbook.

Link to comment
Share on other sites

I believe that this Subroutine will do what you want

 

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Cell As Range
For Each Cell In Target
With Cell
If .Column = Range("B:B").Column Then
Cells(.Row, "A").Value = Int(Now)
End If
End With
Next Cell
End Sub

 

 

cool

 

 

so where do i put it? what do i do with it? :rolleyes:

 

I havent got Excel to hand but I believe that if you go into Tools>Macros>Visual Basic Editor then you'll get two panes, the left hand side has a sort of navigation tree, click on the worksheet you're wanting to do it on and cthe right hand pane will go clear. Paste it in there to attach it to that Workbook.

 

i must be doing something wrong as it seems to have no effect on anything! my lack of VB knowledge isnt helping me out much like!

Link to comment
Share on other sites

If you're okay with the date/time stamp updating whenever you update the values in column B then this'll do the job

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Cell As Range
For Each Cell In Target
With Cell
If .Column = Range("B:B").Column Then
Cells(.Row, "A").Value = Int(Now)
End If
End With
Next Cell
End Sub

 

 

cool

 

 

so where do i put it? what do i do with it? <_<

 

I havent got Excel to hand but I believe that if you go into Tools>Macros>Visual Basic Editor then you'll get two panes, the left hand side has a sort of navigation tree, click on the worksheet you're wanting to do it on and cthe right hand pane will go clear. Paste it in there to attach it to that Workbook.

 

i must be doing something wrong as it seems to have no effect on anything! my lack of VB knowledge isnt helping me out much like!

 

At the bottom of your workbook, you should have different tabs for each sheet. If you haven't renamed them and still got your defaults, it'll be Sheet1, Sheet2, Sheet3.

 

Right-click on Sheet1 and, from the pop-up menu, select 'View Code' - This will launch the VBA editor.

 

By default, your current workbook should be the top window in the right pane - if it's a brand new workbook, the window title will be 'Book1 - Sheet1 (Code)'

 

You'll have two dropdown menus at the top, the left one will be defaulted to '(General)' and the right one '(Declarations)'

 

Click the down arrow for the left dropdown menu and select 'Worksheet'

 

The right dropdown should default to 'SelectionChange', click the down arrow in the right dropdown and select 'Change'

 

The will already give you the 'Private Sub... ...End Sub' lines from Pud's code so you'll just need to paste the other lines inbetween.

 

Once done, go back to your workbook and test!

 

Edit, if you also want the timestamp recorded, then instead of 'Int(Now)', just use 'Now'

Edited by MrBass
Link to comment
Share on other sites

Which method are you using - Pud's super method or my simple one?

 

Either way, you'll need to make sure column is formatted correctly, right-click, Format Cells..., select the Custom category and in the Type: field, enter DD/MM/YYYY HH:MM:SS or whatever format you like.

Link to comment
Share on other sites

Which method are you using - Pud's super method or my simple one?

 

Either way, you'll need to make sure column is formatted correctly, right-click, Format Cells..., select the Custom category and in the Type: field, enter DD/MM/YYYY HH:MM:SS or whatever format you like.

 

your method i thinki, i right clicked the worksheet and input the code that way.

 

I've formated the cells now to include the time but it always comes up as 00:00 <_<

Link to comment
Share on other sites

Which method are you using - Pud's super method or my simple one?

 

Either way, you'll need to make sure column is formatted correctly, right-click, Format Cells..., select the Custom category and in the Type: field, enter DD/MM/YYYY HH:MM:SS or whatever format you like.

 

your method i thinki, i right clicked the worksheet and input the code that way.

 

I've formated the cells now to include the time but it always comes up as 00:00 <_<

 

That's Pud's method and:

Edit, if you also want the timestamp recorded, then instead of 'Int(Now)', just use 'Now'
<_<
Link to comment
Share on other sites

Which method are you using - Pud's super method or my simple one?

 

Either way, you'll need to make sure column is formatted correctly, right-click, Format Cells..., select the Custom category and in the Type: field, enter DD/MM/YYYY HH:MM:SS or whatever format you like.

 

your method i thinki, i right clicked the worksheet and input the code that way.

 

I've formated the cells now to include the time but it always comes up as 00:00 :telephone:

 

That's Pud's method and:

Edit, if you also want the timestamp recorded, then instead of 'Int(Now)', just use 'Now'
<_<

 

 

oh yeah <_< thanks mate. working like a dream now

Link to comment
Share on other sites

  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.