'Copy from Master WorkBook to multiple WorkBooks [closed]
I have an updated annual CapEx amount for individual properties that I need to update in 100 excels. Each property has its future capex for years 2021, 2022, 2023 and so on. I need to copy the information from the main list into the model and then copy and paste the updated output value into a separate sheet.
The above explanation is for illustrative purposes so that what I am trying to do is more clear.
I essentially need a loop or offset copy and paste from the master workbook to other workbooks. I have gone through several other examples but nothiung seems to be working.
My main issues is with the copy loop and getting it to copy and paste the rows as it opens the relevant files.
CapEx paste area and output value
Code:
Sub CapExUpdate()
enter code here
Dim FilePath As String
Dim Model As String
Dim Source As String
Dim i As Integer
Dim n As Integer
Do While n <= 10
n = 5
n = n + 1
FilePath =
Workbooks("Macro.xlsm").Worksheets("Sheet1").Range("D2").Value
'Books
Model = Workbooks("Macro.xlsm").Worksheets("Sheet1").Range("D" &
n).Value
'Source
Source =
Workbooks("Macro.xlsm").Worksheets("Sheet1").Range("D4").Value
Workbooks.Open "" & FilePath & "\" & Model & ""
Workbooks.Open "" & FilePath & "\" & Source & ""
'Copy Paste
'Source Copy
Workbooks("" & Source & "").Activate
Worksheets("Sheet1").Activate
i = 5
i = i + 1
Range("D" & i & ":H" & i).Select
Range("D" & i & ":H" & i).SpecialCells(xlCellTypeVisible).Copy
'Book Paste
Workbooks("" & Model & "").Activate
Range("D6:H6").Select
Selection.PasteSpecial (xlPasteValues)
If n = 10 Then
Exit Do
End If
Loop
Application.CutCopyMode = False
End Sub
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

