J7House1984
New Member
- Joined
- Oct 30, 2020
- Messages
- 21
- Office Version
- 365
- Platform
- Windows
I am working on making creating an archive of UTMs that have been created using a simple form. I am having issues with the pasting portion. My VBA code will insert a line and then insert the timestamp into column B in the "UTM Log" worksheet as required, however it is not capturing the UTM in the "UTM Template" worksheet. I am receiving a blank in cell "A2" of the "UTM Log" worksheet.
I know I have not done something correctly but I can't figure out exactly what it is. I have added screenshots as reference. Please let me know if you have any questions and I will try to answer them the best I can.
Template: B27 is the cell I want to copy and paste
Log (Archiving worksheet) Column A is where I want the value of UTM Template cell B27 to go with the timestamp.
VBA Code:
Sub Archiving()
Dim wsFrom As Worksheet: Set wsFrom = Sheets("UTM Template")
Dim wsTo As Worksheet: Set wsTo = Sheets("UTM Log")
Dim copyRng As Range
Dim TimeStamp As String
TimeStamp = Format(CStr(Now), "mm-dd-yyyy hh:mm") 'format the timestampt
Set copyRng = wsFrom.Range("B27") 'set your copy range
wsTo.Range("A2:B" & copyRng.Rows.Count + 1).Insert Shift:=xlDown 'insert rows into sheet before pasting data
copyRng.Copy
wsTo.Range("A2").PasteSpecial xlPasteValues 'paste data into newly inserted empty rows
wsTo.Range("B2").Value = TimeStamp 'add timestampt to copied range
End Sub
I know I have not done something correctly but I can't figure out exactly what it is. I have added screenshots as reference. Please let me know if you have any questions and I will try to answer them the best I can.
Template: B27 is the cell I want to copy and paste
Log (Archiving worksheet) Column A is where I want the value of UTM Template cell B27 to go with the timestamp.