chrishlee1228
New Member
- Joined
- Apr 25, 2022
- Messages
- 5
- Office Version
- 365
- Platform
- Windows
VBA Code:
Sub Copy_Sheets_To_Master()
Application.ScreenUpdating = False
Dim wkbSource As Workbook, wsDest As Worksheet, ws As Worksheet, lRow As Long
Set wsDest = ThisWorkbook.Sheets("Master")
Set wkbSource = Workbooks.Open("Z:\Filelocation\" & Range("A1"))
For Each ws In Sheets(Array("Sheet1", "Sheet3", "Sheet4", "Sheet5"))
With ws
lRow = .Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
.Cells(2, 1).Resize(lRow - 1, 7).Copy wsDest.Cells(wsDest.Rows.Count, "A").End(xlUp).Offset(1)
End With
Next ws
wkbSource.Close False
Application.ScreenUpdating = True
End Sub
Regarding this code is there a way to copy all sheets based on tab names listed in another tab of the macro workbook? For example the list in a tab labeled "tabs" contains a list of tabs that I want copy and pasted: "Sheet1", "Sheet2", etc. instead of having to update it in the VBA screen every time there is a new updated tab?
Also I want a conditional copy/paste where if in my column labeled "Already Pasted" for each line of data with a string text has a "Yes" then we don't copy that line; we only copy/paste "No" so that we aren't duplicating any data transfers. Can this be done?