VBA Macro Timestamp an empty cell in a column

antrams

New Member
Joined
Oct 8, 2014
Messages
9
I'm new to VBA and needs to create a timestamp to record time in every transactions. What I want is that each time I press a key (CTRL+key) the time will automatically appear in an empty cell without selecting it.

For Example:

Sheetname: Sheet1
Column: C <--- under C when i use macro, timestamp in C1 will appear.
Target: Blank Cell under Column C (c1,c2, and so on).


Need help badly, I would be very glad if someone can help me out.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Welcome to the board!

You can assign a key to this:
Code:
Sub timestamp()
With Sheets("Sheet1")
    If IsEmpty(.Range("C1")) Then
        .Range("C1").Value = Now
    Else
        .Range("C" & .Cells(.Rows.Count, "C").End(xlUp).Row + 1).Value = Now
    End If
End With
End Sub
 
Upvote 0
Hi Joe,
This really helped me alot, thank you so much for saving me..
and also thanks for the warm welcome :D
 
Upvote 0
Someone asked me if I can to do it in another sheet (sheet2,sheet3...) I tried using the code above and found out that each time i use the macro in sheet2, the time will appear in sheet1.. is there a way I would be able to use it in different sheets without populating another sheet?

I mean, if I want it only in sheet2 (or any sheet) it will only populate sheet I wanted, like Activesheet... sorry for being a newbie..
 
Upvote 0
Someone asked me if I can to do it in another sheet (sheet2,sheet3...) I tried using the code above and found out that each time i use the macro in sheet2, the time will appear in sheet1.. is there a way I would be able to use it in different sheets without populating another sheet?

I mean, if I want it only in sheet2 (or any sheet) it will only populate sheet I wanted, like Activesheet... sorry for being a newbie..

Replace "Sheet1" with "Sheet2" in the second line of the code I posted.
 
Upvote 0
Did you leave the old macro in place and install a new one with Sheet1 replaced by Sheet2 or did you make the replacement in the old macro? Are you using the same key?

If you simply make the replacement in the old macro, there's no way it will continue to stamp sheet1.
 
Upvote 0
I just copied the code from sheet1 and pasted it in sheet2 with the same key used. I want the macro to be used in a workbook, like for 10 or more sheets, there will be one macro that is being used which is the timestamp. And each time I use it, the time stamps only in a selected sheet. sorry for my english.
 
Upvote 0
I just copied the code from sheet1 and pasted it in sheet2 with the same key used. I want the macro to be used in a workbook, like for 10 or more sheets, there will be one macro that is being used which is the timestamp. And each time I use it, the time stamps only in a selected sheet. sorry for my english.
It's NOT sheet code - belongs in a standard module. AND you must replace Sheet1 (one place in the code) with Sheet2.
 
Upvote 0

Forum statistics

Threads
1,214,923
Messages
6,122,286
Members
449,076
Latest member
kenyanscott

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