copy data from one worksheet to identical sheet in different workbook

A

akid12

I want to essentially sync the data between 2 identical worksheets in
different workbooks. Essentially, I want to import and replace data in
the second sheet with data from the first, is there a simple way to do
this without deleting the worksheet and then copying the new sheet into
the workbook?

Thanks
 
B

Bonzo123

Sub Post()

' change the word OUT to the name of the sheet in your workbook
' change the A1:BB200 to the name of the range that you wany to
copy
' the next line copies an area of the worksheet called out
Worksheets("Out").Range("A1:BB200").Copy

'In any sheet in your workbook type in the full path and name of
the receiving file
' e.g. c:\my folder\ReceivingFile.xls
' create a named range (select the cell and select Insert > Name >
Define
' type in a name into the dialog box
' I selected ToFile as my name. You can use any name you require
' if you select a different name then change the work ToFile below
to the name that you chose
' the next line opens the receiving file
Workbooks.Open Filename:=Range("ToFile")

' change the word IN to the name of the sheet in your receiving
workbook
' the next line opens correct wothsheet in the receiving file
Worksheets("IN").Range("A1").Select

' the next line pastes values and formats into the receiving
worksheet

Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False
ActiveWorkbook.Protect Structure:=True, Windows:=False


' the next line saves and closes the receiving file
ActiveWorkbook.SaveAs Filename:=filenam, FileFormat:=xlNormal,
Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWorkbook.Close
End Sub


' notes
' If you already have macros in you workbook then copy this into a new
macro.
' if you do not have any macros the select Tools > Macros > Visual
basic editor
' then select Insert > module
' Double click the module to open it
' paste the above into the new module


'Regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top