• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Adding Timestamp to existing Macro

mgao77

New Member
Hello All,

I have an existing macro that takes data from one sheet and posts into another sheet. This process will be occuring monthly, therefore, I need an add on to the macro that will allow me to timestamp each time this happens If data from the previous month changes.

this is my current macro:


Code:
Sub Copydata()
'
' Copydata Macro
'
 
 
'
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Range("A1").Select
Sheets("Data").Select
Sheets("Data").Select
ActiveSheet.Previous.Select
Selection.End(xlDown).Select
Range("A731").Select
Selection.End(xlUp).Select
Sheets("Data").Select
Range("A" & Sheets("Data").UsedRange.Rows.Count + 1).Select
ActiveSheet.Paste
Application.CutCopyMode = False
 
End Sub


Can anyone help add on this timestamp please?

Thanks in advance
 
When you say time stamp.. where do you need it? For example, if you write this at the end of your code, it will put a time stamp in Range("B2")

Code:
Range("B2").Value = Now()
 
Code:
Sub Copydata()
...
Range("A731").Select
Selection.End(xlUp).Select
...
End Sub
Hi, mgao77!
Take care of this fixed reference, if there're months with more than 730 rows of data it won't work. Give a look at the following snippet extracted from this topic:
http://chandoo.org/forum/threads/creating-many-lists-from-a-report.12264
Code:
...
    Dim drc as Long
---
    If Range("A" & ActiveSheet.Rows.Count).Value <> "" Then
        drc = ActiveSheet.Rows.Count
    Else
        drc = Range("A" & ActiveSheet.Rows.Count).End(xlUp).Row
    End If
...
Hope it helps.
Regards!
 
Back
Top