Good Morning Guys,


I am trying to copy a selected range from worksheet (or copying the whole worksheet) from file A, create a new workbook(name it and rename a worksheet in it). Then paste copied worksheet or range into new workbook.

Please let me know what code to use, thanks.

Ini

Do not worry about it guys, I figured it out thank you regardless.

Below is the code I used, hopefully it will help someone else in the future :).

wb.Sheets("Shift Report").Visible = -1
    wb.Sheets("Shift Report").Select
    Range("A1:N31").Select
    Selection.Copy
 
    Set wc = Workbooks.Add
    Range("A1").Select
    ActiveSheet.Paste
    wc.ActiveSheet.name = "Shift Report"
    Application.DisplayAlerts = False
    wc.SaveAs Filename:="C:\First Shift" & " " & Zt & ".xls", FileFormat:=xlWorkbookNormal, addtomru:=True
    Application.DisplayAlerts = True
    wc.Save
    wc.Close
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.