Simple sheet copy macro required for new workbook

PCMK99

New Member
Joined
Dec 10, 2019
Messages
10
Office Version
  1. 365
Platform
  1. Windows
I am trying to find a macro that will copy a sheet from my original workbook to a new workbook (doesn't need to be saved or named at this point) and then go back to my original workbook and delete that sheet plus some more actions in the original workbook like hiding sheets.
What needs to be left is the original workbook open and the newly created workbook with the sheet available for editing as required.
I have got so far but as soon as the new workbook is created the macro stops and fails to follow the rest of the instructions to go back to the original workbook and delete the sheet and hide the sheet.
Any help appreciated. .

Sub Mymacro()
Dim w As Workbook, x As Workbook
Set w = ThisWorkbook
Application.ScreenUpdating = False

'copy sheet to a new workbook
Sheets("PRNT2").Copy
Set x = ActiveWorkbook

'go back to original workbook
ThisWorkbook.Activate

'delete "PRNT2" sheet
Sheets("PRNT2").Select
ActiveWindow.SelectedSheets.Delete

'Hide "PRNT1" sheet
Sheets("PRNT1").Hide


End Sub
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
How about
VBA Code:
Sub PCMK()
   With ThisWorkbook
      .Sheets("PRNT2").Move
      .Sheets("PRNT1").Visible = xlSheetHidden
   End With
End Sub
 
Upvote 0
How about
VBA Code:
Sub PCMK()
   With ThisWorkbook
      .Sheets("PRNT2").Move
      .Sheets("PRNT1").Visible = xlSheetHidden
   End With
End Sub

FLUFF......the ".move" did it for me in combination with a few other bits.....THANKS !!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,928
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top