VBA Time/date stamp when copy/pasting values

tpowell1986

New Member
Joined
Jun 23, 2021
Messages
14
Office Version
  1. 365
Platform
  1. Windows
hi,

i need of some help please, i have a simple script that is copying values from a workbook to the next empty row on another tab, i would like to have a time and date stamp in column B showing when the information was pasted.

thanks in advance

Range("t2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Sheets("invoice").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
How about
VBA Code:
Range("t2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
With Sheets("invoice").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
   .PasteSpecial xlPasteValues
   .Offset(, 1).Resize(Selection.Rows).Value = Now
End With
 
Upvote 0
How about
VBA Code:
Range("t2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
With Sheets("invoice").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
   .PasteSpecial xlPasteValues
   .Offset(, 1).Resize(Selection.Rows).Value = Now
End With
thanks for the reply, it debugs on this line? .Offset(, 1).Resize(Selection.Rows).Value = Now
 
Upvote 0
It works for me, what error do you get?
 
Upvote 0
1626378160164.png

Hi, error attached, when you debug it stops on the .Offset(, 1).Resize(Selection.Rows).Value = Now line, column A has copied but nothing in column B when it stops
 
Upvote 0
What happens if you use
VBA Code:
VBA.Now
 
Upvote 0
Sub Macro1()
'
' Macro1 Macro
'

'
Sheets("Alliance").Select
ActiveSheet.ListObjects("Query1_2").Range.AutoFilter Field:=21, Criteria1:= _
"Yes"
Range("t2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Sheets("invoice").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Sheets("Alliance").Select
ActiveWorkbook.Worksheets("Alliance").ListObjects("Query1_2").Sort.SortFields. _
Clear
ActiveSheet.ShowAllData
End Sub
 
Upvote 0
That doesn't include the suggestion that I made.
 
Upvote 0
sorry i had not saved the file and closed it, code would be

Sub Macro1()
'
' Macro1 Macro
'

'
Sheets("Alliance").Select
ActiveSheet.ListObjects("Query1_2").Range.AutoFilter Field:=21, Criteria1:= _
"Yes"

Range("t2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
With Sheets("invoice").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
.PasteSpecial xlPasteValues
.Offset(, 1).Resize(Selection.Rows).Value = Now
End With

Sheets("Alliance").Select
ActiveWorkbook.Worksheets("Alliance").ListObjects("Query1_2").Sort.SortFields. _
Clear
ActiveSheet.ShowAllData
End Sub
 
Upvote 0
Try what I suggested in post#6
 
Upvote 0

Forum statistics

Threads
1,214,386
Messages
6,119,217
Members
448,876
Latest member
Solitario

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