jeudi 28 avril 2016

Two workbooks, Same Sheets Names: Copy and Paste if Sheets are matched

I have two workbooks, with same sheets name (but in different order), and I'd like to copy info of all of the sheets of one workbook, and pasting that info in the respective sheet of the other workbook (matching sheet names). I feel like this code is on track, but maybe there is a more efficient or cleaner way to do this. Code is working, but it says a warning like " there's a big amount of data in the windows clipboard... etc... "

Sub ActualizarNoticias()
     Dim aw As Workbook
     Dim y As Workbook

Set aw = Application.ActiveWorkbook
Set y = Application.Workbooks.Open("G:\Estudios\Biblioteca\Mercado Accionario Chileno\BBDD Oficial.xlsm")


For i = 1 To aw.Sheets.Count
For j = 1 To y.Sheets.Count

If aw.Worksheets(i).Name = y.Worksheets(j).Name Then

y.Worksheets(j).Range("A3").Copy
aw.Worksheets(i).Range("A100").PasteSpecial
End If

Next j
Next i

y.close
' ActualizarNoticias Macro
'
'
End Sub

Aucun commentaire:

Enregistrer un commentaire