0

How can I reference to the new sheet after its copied as a new workbook.

Dim MainWb As Workbook: Set MainWb = ThisWorkbook
Dim SheetToCopy As Worksheet: Set SheetToCopy = MainWb.ActiveSheet

SheetToCopy.Copy

Is there a way to define a name to it? Someting like

 Set CopiedSheet = SheetToCopy.Copy
Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
luke
  • 482
  • 4
  • 12
  • 29

1 Answers1

0

When you copy a sheet it becomes the ActiveSheet, so you can reference that.

Dim MainWb As Workbook: Set MainWb = ThisWorkbook
Dim SheetToCopy As Worksheet: Set SheetToCopy = MainWb.ActiveSheet
Dim CopiedSheet As Worksheet

SheetToCopy.Copy 

Set CopiedSheet = ActiveWorkbook.ActiveSheet 
drec4s
  • 7,946
  • 8
  • 33
  • 54
  • When I use `.Copy` it creates a new workbook I want to reference to the sheet after its copied to a new workbook. – luke May 02 '19 at 18:46
  • You need to reference the `activesheet` then. I've updated the answer. – drec4s May 02 '19 at 19:09