Wolfgang17
Board Regular
- Joined
- Nov 8, 2010
- Messages
- 63
I would like to copy data from a single range of cells from multiple sheets to the same range and sheets in another workbook. The workbooks are identical other than the missing cell values.
Any help would be appreciated.
Some of the code has been commented out as trial end error.
Any help would be appreciated.
Some of the code has been commented out as trial end error.
Code:
Sub CopyData()
Dim x As Workbook
Dim y As Workbook
Dim CopyRng As Range
'## Open both workbooks first:
Set x = Workbooks.Open(" C:\Desktop\Copy Test/2017 Timecard_Original.xlsm ")
Set y = Workbooks.Open(" C:\Desktop\Copy Test/2017 Timecard_Backup.xlsm ")
'Now, transfer values from x to y:
y.Sheets("Pay1").Range("B5:N47").Value = x.Sheets("Pay1").Range("B5:N47")
' Loop through all worksheets and copy the data to the
y.Activate
For Each sh In ActiveWorkbook.Sheets(Array("Pay1", "Pay2", "Pay3", "Pay4", "Pay5", "Pay6", "Pay7", "Pay8", "Pay9", _
"Pay10", "Pay11", "Pay12", "Pay13", "Pay14", "Pay15", "Pay16", "Pay17", "Pay18", "Pay19" _
, "Pay20", "Pay21", "Pay22", "Pay23", "Pay24", "Pay25", "Pay26"))
' Specify the range to place the data.
'Set CopyRng = sh.Range("B5:N47")
'With DestSh.Cells("B5")
'This statement copies values from each worksheet.
'CopyRng.Copy
'.PasteSpecial xlPasteValues
Application.CutCopyMode = False
End With