Copy from Master Book
This will copy the current selection of the Workbook named cMaster
(master.xlsm
) to the cell cRange
(A1
) of every other open workbook's ActiveSheet
.
The Code
Option Explicit
Sub CopyFromMaster()
Const cMaster As String = "master.xlsm" ' Master Workbook
Const cRange As String = "A1" ' Paste Cell Range
Dim wb As Workbook ' Current Workbook
' Loop through all open workbooks.
For Each wb In Workbooks
' Check if the name of the Current Workbook is different than the name
' of the Master Workbook.
If wb.Name <> cMaster Then
' Copy the selection in Master Workbook to Paste Cell Range
' in ActiveSheet of Current Workbook.
Windows(cMaster).Selection.Copy wb.ActiveSheet.Range(cRange)
End If
Next
End Sub
EDIT
Question in Comments
"How would I go about repeating the same instruction but now copying from sheet 2 of the master workbook and pasting in sheet 2 of the other open workbook?"
Sub CopyFromMaster2()
Const cMaster As String = "master.xlsm" ' Master Workbook
Const cRange As String = "A1" ' Paste Cell Range
Dim wb As Workbook ' Current Workbook
For Each wb In Workbooks
' Check if the name of the Current Workbook is different than the name
' of the Master Workbook.
If wb.Name <> cMaster Then
' Before using selection (select) you have to make sure that
' the worksheet is active or just activate it.
Workbooks(cMaster).Worksheets("Sheet2").Activate
' Copy the selection in "Sheet2" of Master Workbook to
' Paste Cell Range "Sheet2" of Current Workbook.
Selection.Copy wb.Worksheets("Sheet2").Range(cRange)
End If
Next
End Sub