Archiving a cell value from one worksheet to another with timestamp

J7House1984

New Member
Joined
Oct 30, 2020
Messages
21
Office Version
  1. 365
Platform
  1. 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.
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
UTM Template scrnshot.png


Log (Archiving worksheet) Column A is where I want the value of UTM Template cell B27 to go with the timestamp.
UTM Log.png
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Judging by your image B27 is blank, should it be C27?
 
Upvote 0
Solution
Judging by your image B27 is blank, should it be C27?
Oh man I feel like a complete moron. I just changed the B27 and it work perfectly. Man, I was so close. Thank you for catching that for me.
 
Upvote 0
Glad to help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,150
Members
453,021
Latest member
Justyna P

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