Help moving a range of data from one workbook to another

ProdChris

New Member
Joined
Apr 26, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I have a workbook that is used to calculate data. There is a range on the workbook "P2:T2" that needs to be copied and pasted to a log as a record that it has been used. My problem is I don't want duplicate data on the pasted workbook. Is there a way to look for if there is already repeat data based on cell P2 to not paste the data?

Here is my current code (I removed the location of the second workbook). This works but will paste the data every time the calculator workbook is used, I only want one entry per P2 value:

Sub Data_Tracking()
' copy data
Range("P2:T2").Copy
' open test workbook
Workbooks.Open "location.test.xlsx"
' paste data
Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
' save and close test workbook
Workbooks("Test.xlsx").Close SaveChanges:=True
End Sub
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Forum statistics

Threads
1,215,035
Messages
6,122,791
Members
449,095
Latest member
m_smith_solihull

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