VBA copy Value from Cell that uses (TODAY)

nikeymikey

New Member
Joined
Jan 14, 2020
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have an order form document that i have created in Excel, everything is working perfectly except for one thing.
This is how the form works.

Me or a colleague will fill in the details on the "Order Form" sheet, we will print a hard copy of said order form. After finishing with the order, click on a button that copy's all order data to a separate sheet titled "Orders" and then clears the sheet ready for the next use.

As i said everything works except one thing. As the order from uses the (TODAY) function to auto populate the date, when copying over to the "Orders" sheet it is copying the entire formula and not just the value. This is a problem because every day when the workbook is first opened all the dates on the order sheet get updated to that days date hence corrupting the historical data. I have copied my code below, i know you experts will probably find it messy, i have managed to cobble it together with some help from the internet and it works..... almost :)

VBA Code:
Private Sub CommandButton3_Click()
ActiveWorkbook.Unprotect "5t6y7u8i"
    For Each ws In Worksheets
        ws.Unprotect "5t6y7u8i"
    Next
   
    Dim pasterange As Long
pasterange = ThisWorkbook.Sheets("Orders").Range("A" & Rows.Count).End(xlUp).Row + 1 ' the plus 1 is to get the next blank row

***ThisWorkbook.Sheets("Order Form").Range("B3").Copy Destination:=ThisWorkbook.Sheets("Orders").Range("A" & pasterange)***
ThisWorkbook.Sheets("Order Form").Range("F3").Copy Destination:=ThisWorkbook.Sheets("Orders").Range("B" & pasterange)
ThisWorkbook.Sheets("Order Form").Range("S6").Copy Destination:=ThisWorkbook.Sheets("Orders").Range("C" & pasterange)
ThisWorkbook.Sheets("Order Form").Range("S8").Copy Destination:=ThisWorkbook.Sheets("Orders").Range("D" & pasterange)
ThisWorkbook.Sheets("Order Form").Range("S9").Copy Destination:=ThisWorkbook.Sheets("Orders").Range("E" & pasterange)
ThisWorkbook.Sheets("Order Form").Range("S10").Copy Destination:=ThisWorkbook.Sheets("Orders").Range("F" & pasterange)
ThisWorkbook.Sheets("Order Form").Range("S11").Copy Destination:=ThisWorkbook.Sheets("Orders").Range("G" & pasterange)
ThisWorkbook.Sheets("Order Form").Range("S12").Copy Destination:=ThisWorkbook.Sheets("Orders").Range("H" & pasterange)
ThisWorkbook.Sheets("Order Form").Range("S13").Copy Destination:=ThisWorkbook.Sheets("Orders").Range("I" & pasterange)
ThisWorkbook.Sheets("Order Form").Range("S14").Copy Destination:=ThisWorkbook.Sheets("Orders").Range("J" & pasterange)
ThisWorkbook.Sheets("Order Form").Range("S19").Copy Destination:=ThisWorkbook.Sheets("Orders").Range("K" & pasterange)
ThisWorkbook.Sheets("Order Form").Range("S20").Copy Destination:=ThisWorkbook.Sheets("Orders").Range("L" & pasterange)
ThisWorkbook.Sheets("Order Form").Range("S21").Copy Destination:=ThisWorkbook.Sheets("Orders").Range("M" & pasterange)
ThisWorkbook.Sheets("Order Form").Range("S22").Copy Destination:=ThisWorkbook.Sheets("Orders").Range("N" & pasterange)
ThisWorkbook.Sheets("Order Form").Range("S23").Copy Destination:=ThisWorkbook.Sheets("Orders").Range("O" & pasterange)
ThisWorkbook.Sheets("Order Form").Range("S24").Copy Destination:=ThisWorkbook.Sheets("Orders").Range("P" & pasterange)
ThisWorkbook.Sheets("Order Form").Range("S25").Copy Destination:=ThisWorkbook.Sheets("Orders").Range("Q" & pasterange)
ThisWorkbook.Sheets("Order Form").Range("S26").Copy Destination:=ThisWorkbook.Sheets("Orders").Range("R" & pasterange)
ThisWorkbook.Sheets("Order Form").Range("S27").Copy Destination:=ThisWorkbook.Sheets("Orders").Range("S" & pasterange)
ThisWorkbook.Sheets("Order Form").Range("S28").Copy Destination:=ThisWorkbook.Sheets("Orders").Range("T" & pasterange)
ThisWorkbook.Sheets("Order Form").Range("S29").Copy Destination:=ThisWorkbook.Sheets("Orders").Range("U" & pasterange)
ThisWorkbook.Sheets("Order Form").Range("S30").Copy Destination:=ThisWorkbook.Sheets("Orders").Range("V" & pasterange)
ThisWorkbook.Sheets("Order Form").Range("S31").Copy Destination:=ThisWorkbook.Sheets("Orders").Range("W" & pasterange)
ThisWorkbook.Sheets("Order Form").Range("S32").Copy Destination:=ThisWorkbook.Sheets("Orders").Range("X" & pasterange)
ThisWorkbook.Sheets("Order Form").Range("S34").Copy Destination:=ThisWorkbook.Sheets("Orders").Range("Y" & pasterange)
ThisWorkbook.Sheets("Order Form").Range("T38").Copy Destination:=ThisWorkbook.Sheets("Orders").Range("Z" & pasterange)
ThisWorkbook.Sheets("Order Form").Range("G10").Copy Destination:=ThisWorkbook.Sheets("Orders").Range("AA" & pasterange)
ThisWorkbook.Sheets("Order Form").Range("C40").Copy Destination:=ThisWorkbook.Sheets("Orders").Range("AB" & pasterange)
ThisWorkbook.Sheets("Order Form").Range("G40").Copy Destination:=ThisWorkbook.Sheets("Orders").Range("AC" & pasterange)
ThisWorkbook.Sheets("Order Form").Range("S36").Copy Destination:=ThisWorkbook.Sheets("Orders").Range("AD" & pasterange)

Application.CutCopyMode = False
Range("S6", "S14").Value = " "
Range("S19", "S32").Value = " "
Range("T38").Value = " "
Range("G10").Value = " "
Range("C40").Value = " "
Range("G40").Value = " "
Range("S34").Value = " "
Range("S36").Value = "0.00"
ThisWorkbook.Sheets("JLR Profit Sheet").Range("E26").Value = " "
ThisWorkbook.Sheets("JLR Profit Sheet").Range("E27").Value = " "
ThisWorkbook.Sheets("JLR Profit Sheet").Range("E28").Value = " "
ThisWorkbook.Sheets("JLR Profit Sheet").Range("E31").Value = " "
ThisWorkbook.Sheets("JLR Profit Sheet").Range("C16").Value = " "
ThisWorkbook.Sheets("Other Brands").Range("E26").Value = " "
ThisWorkbook.Sheets("Other Brands").Range("E27").Value = " "
ThisWorkbook.Sheets("Other Brands").Range("E28").Value = " "
ThisWorkbook.Sheets("Other Brands").Range("E29").Value = " "
ThisWorkbook.Sheets("Other Brands").Range("E31").Value = " "
ThisWorkbook.Sheets("Other Brands").Range("C16").Value = " "
ActiveWorkbook.Unprotect "password"
   
    For Each ws In Worksheets
        ws.Protect "5t6y7u8i"
    Next
   
    ActiveWorkbook.Protect "5t6y7u8i"
ActiveWorkbook.Save
End Sub

***PASSWORD HAS BEEN CHANGED BEFORE ANYONE COMMENTS ON IT :)***

The line i have highlighted with *** is the one that copies and pastes the date cell. I can upload a copy of my sheet if needed :)

Any help is massively appreciated as once this if fixed i can put this sheet live in our office :)
 
Last edited by a moderator:

Some videos you may like

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,626
Office Version
  1. 365
Platform
  1. Windows
Change that line to this
VBA Code:
ThisWorkbook.Sheets("Orders").Range("A" & pasterange).Value=ThisWorkbook.Sheets("Order Form").Range("B3").Value
 

nikeymikey

New Member
Joined
Jan 14, 2020
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Change that line to this
VBA Code:
ThisWorkbook.Sheets("Orders").Range("A" & pasterange).Value=ThisWorkbook.Sheets("Order Form").Range("B3").Value

This works perfectly at first glance, thank you for your help, it is greatly appreciated :)
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,626
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback
 

Watch MrExcel Video

Forum statistics

Threads
1,127,738
Messages
5,626,606
Members
416,194
Latest member
Dhisilva_aguiar

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
Top