Copy data to archive

emukiss10

Board Regular
Joined
Nov 17, 2017
Messages
201
Hello.

I need help.

I have a file named ARCHIVE. It has only headers. I need a VBA script to copy contents of another workbooks to Archive ranged "B2" to Lastrow "Z" and it should be inserted to next free row in Archive.

Couple ppl will work on some files and at the end they should add their work to Archive. So i should expand. I would like to add this macro to a button and it should pop msgbox with YES/NO confirmation "Do you want to add your work to archive?". The copy should be made by exporting current work to archive not by importing files to archive.

Its beyond my knowledge.

Best Regards
W.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
you cannot export data.
The target file ARCHIVE will have to be opened, then locate the last row, then paste new values.
 
Upvote 0
That can be done. Open it with macro, copy data, save and close. BUT I cannot do it myself.. Above my skills :(
 
Upvote 0
Please make it work :)

open other xls file, copy everything from sheet 1 A2 to ZlastRow activeWB into sheet 1 opened (archive) under last row so it can expand.
 
Upvote 0
Ive managed to do it myself - it took me very long time thou'

Code:
Dim WB1 As Workbook
Dim WB2 As Workbook
Dim LastRow As Long


Set WB1 = ActiveWorkbook
Set WB2 = Workbooks.Open("C:\MyArchiveFile.xlsx")


With WB2.Sheets("MyArchiveSheet")
    LastRow = .Range("A" & .Rows.count).End(xlUp).row
End With

WB1.Sheets("MySourceSheet").Range("AB:Z" & LastRow).Copy
With WB2.Sheets("MyArchiveSheet").Cells(Rows.count, 1).End(xlUp).Offset(1, 1)
        .PasteSpecial xlPasteColumnWidths
        .PasteSpecial xlPasteValues, , False, False
        .PasteSpecial xlPasteFormats, , False, False
End With

WB2.Save
WB2.Close

Close Thread

Thank You
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

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