The Worksheet.Copy method does not return a link to a new workbook. Instead, you can use the Worksheet link:
Dim wsCopy As Excel.Worksheet 'changed from wb to wsCopy
As you know, if you did not provide an After or Before argument, it copies the new workbook. Copying within the same book will use this code:
Set wsCopy = wb.Worksheets("Overview") wsCopy.Copy After:= wb.Worksheets(1) 'or Before:=
If you want to copy a sheet into a new book and save a link to it, you need to do this in stages:
Dim wbNew As Excel.Workbook Dim wsCopied As Excel.Worksheet Set wbNew = Workbooks.Add wsCopy.Copy before:=wbNew.Worksheets(1) Set wsCopied = wbNew.Worksheets(1)
If you only need to keep the link to the new book, just omit the last line (and the variable declaration for wsCopied).
source share