ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy and paste new records only (https://www.excelbanter.com/excel-programming/359417-copy-paste-new-records-only.html)

Mike G - D.C.

Copy and paste new records only
 
Hello €“
Im not well versed in Excel programming, but will describe what I'm trying
to accomplish.

I have a worksheet (Export Data) with data in columns A through S, Rows 2
through 21389. The data is pulled in from a few other worksheets using
formulas. As it is right now, I have a macro set up that will copy all of the
values from A2 through S21389 and pastes into another spreadsheet, converts
all dates to a specific format and saves as a.txt file within a specific
folder. The issue is however, that this macro will copy everything from A1
through S21389, every time that it is activated. In a perfect world, this
macro would only copy items that have changed since the last time the macro
was run, therefore only exporting new data.

My thought process is as follows, any time new data is carried over within
the Export Data worksheet, anywhere within columns A through S, an X placed
in Column T within the applicable row. The macro would be reset to copy only
rows with an X in Column T. Then, the last step of the macro would clear out
all of the Xs so that only new items will export the next time the macro is
run. Is this possible?

Any advice will be greatly appreciated, Mike


Gary''s Student

Copy and paste new records only
 
You can accomplish your goal, however, it is very likely that multiple
copy/pastes will actually take longer than a single one:

Sub Macro1()
Dim r1, r2 As Range
Set r1 = Worksheets("Sheet1").Range("A1:S21389")
Set r2 = Worksheets("Sheet2").Range("A1")
r1.Copy r2
End Sub


--
Gary''s Student


"Mike G - D.C." wrote:

Hello €“
Im not well versed in Excel programming, but will describe what I'm trying
to accomplish.

I have a worksheet (Export Data) with data in columns A through S, Rows 2
through 21389. The data is pulled in from a few other worksheets using
formulas. As it is right now, I have a macro set up that will copy all of the
values from A2 through S21389 and pastes into another spreadsheet, converts
all dates to a specific format and saves as a.txt file within a specific
folder. The issue is however, that this macro will copy everything from A1
through S21389, every time that it is activated. In a perfect world, this
macro would only copy items that have changed since the last time the macro
was run, therefore only exporting new data.

My thought process is as follows, any time new data is carried over within
the Export Data worksheet, anywhere within columns A through S, an X placed
in Column T within the applicable row. The macro would be reset to copy only
rows with an X in Column T. Then, the last step of the macro would clear out
all of the Xs so that only new items will export the next time the macro is
run. Is this possible?

Any advice will be greatly appreciated, Mike


Mike G - D.C.

Copy and paste new records only
 
Gary's Student -
I really appreciate the quick response. How does the code distinguish from
old data entries and new data entries?
Again, I really appreciate the help and quick response, Mike


"Gary''s Student" wrote:

You can accomplish your goal, however, it is very likely that multiple
copy/pastes will actually take longer than a single one:

Sub Macro1()
Dim r1, r2 As Range
Set r1 = Worksheets("Sheet1").Range("A1:S21389")
Set r2 = Worksheets("Sheet2").Range("A1")
r1.Copy r2
End Sub


--
Gary''s Student


"Mike G - D.C." wrote:

Hello €“
Im not well versed in Excel programming, but will describe what I'm trying
to accomplish.

I have a worksheet (Export Data) with data in columns A through S, Rows 2
through 21389. The data is pulled in from a few other worksheets using
formulas. As it is right now, I have a macro set up that will copy all of the
values from A2 through S21389 and pastes into another spreadsheet, converts
all dates to a specific format and saves as a.txt file within a specific
folder. The issue is however, that this macro will copy everything from A1
through S21389, every time that it is activated. In a perfect world, this
macro would only copy items that have changed since the last time the macro
was run, therefore only exporting new data.

My thought process is as follows, any time new data is carried over within
the Export Data worksheet, anywhere within columns A through S, an X placed
in Column T within the applicable row. The macro would be reset to copy only
rows with an X in Column T. Then, the last step of the macro would clear out
all of the Xs so that only new items will export the next time the macro is
run. Is this possible?

Any advice will be greatly appreciated, Mike



All times are GMT +1. The time now is 01:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com