Hi All, I am a VBA novice but have managed to write a script to create a new workbook in my desired location; what I want to do now is copy say 3 or 4 sheets from and exsiting workbook to this new workbook, but all in one routine if thats possible; my logic being create new workbook, then copy said sheets into it - hope that makes sense!
Anyway this code works for creating the new workbook.........
Sub NewWorkBook
Dim NewBook As Workbook
Dim n As Integer
Dim start As Integer
Set NewBook = Workbooks.Add
With NewBook
start = .Worksheets.Count + 1
If start < 5 Then
For n = start To 5
.Sheets.Add After:=Sheets(n - 1)
Next n
For n = 1 To 5
.Worksheets.Name = n
Next n
End If
.SaveAs Filename:="S:\Managers Data Reports-058\Assessment Summaries\ABC.xlsx"
End With
End Sub
Thats fine but then im trying to add in the following code to add specific sheets to that workbook using........................
Workbooks("S:\Managers Data Reports-058\Assessment Summaries\XYZ,xlsx").Sheets("Due in 5-10 Days").Copy _
After:=Workbooks("S:\Managers Data Reports-058\Assessment Summaries\ABC.xlsx").Sheets(Workbooks("S:\Managers Data Reports-058\Assessment Summaries\ABC.xlsx").Sheets.Count)
This is where it falls over and quite honestly I dont have a clue !
Any help as always gratefully received
Anyway this code works for creating the new workbook.........
Sub NewWorkBook
Dim NewBook As Workbook
Dim n As Integer
Dim start As Integer
Set NewBook = Workbooks.Add
With NewBook
start = .Worksheets.Count + 1
If start < 5 Then
For n = start To 5
.Sheets.Add After:=Sheets(n - 1)
Next n
For n = 1 To 5
.Worksheets.Name = n
Next n
End If
.SaveAs Filename:="S:\Managers Data Reports-058\Assessment Summaries\ABC.xlsx"
End With
End Sub
Thats fine but then im trying to add in the following code to add specific sheets to that workbook using........................
Workbooks("S:\Managers Data Reports-058\Assessment Summaries\XYZ,xlsx").Sheets("Due in 5-10 Days").Copy _
After:=Workbooks("S:\Managers Data Reports-058\Assessment Summaries\ABC.xlsx").Sheets(Workbooks("S:\Managers Data Reports-058\Assessment Summaries\ABC.xlsx").Sheets.Count)
This is where it falls over and quite honestly I dont have a clue !
Any help as always gratefully received