Pookiemeister
Well-known Member
- Joined
- Jan 6, 2012
- Messages
- 623
- Office Version
- 365
- 2010
- Platform
- Windows
VBA Code:
Sub CopyWorkbook()
Dim currentSheet as Worksheet
Dim sheetIndex as Integer
sheetIndex = 1
For Each currentSheet in Worksheets
Windows("SOURCE WORKBOOK").Activate
currentSheet.Select
currentSheet.Copy Before:=Workbooks("TARGET WORKBOOK").Sheets(sheetIndex)
sheetIndex = sheetIndex + 1
Next currentSheet
End Sub
I am needing to copy the data from one page of a workbook to another. I found this code on another forum but I can't get it to work with my code. The workbook that the data will be coming from is named "Maintenance Orders and Operations.xlsx". I'm not sure if I needed to add the .xlsx and it will be copied to workbook "WO Report Template 4.1.xlsm". The worksheet it will be copied to will be determined by the week number of the month. Example: We are currently in the first week in this month. So the worksheet is named "Past Due Week 1". Also, if the source workbook is named "Maintenance Orders" that should follow under the first conditional part. Thank you.
VBA Code:
Sub week_num()
Dim WS_Count As Integer
Dim I As Integer
Dim WeekNum As Integer
WS_Count = ActiveWorkbook.Worksheets.Count
WeekNum = Application.WorksheetFunction.RoundUp(Day(Now()) / 7, 0)
For I = 1 To WS_Count
If ActiveWorkbook.Worksheets(I).Name = "WO Week " & (WeekNum) Then
ElseIf ActiveWorkbook.Worksheets(I).Name = "Past Due Week " & (WeekNum) Then
End If
Next I
End Sub