Naming the workbook as the Tab name

VBA learner ITG

Active Member
Joined
Apr 18, 2017
Messages
267
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Thank you for reading my post.

I am new to VBA and I was wondering if you could advise me or guide me in the right direction.

I have the below VBA code to copy a worksheet to a new workbook and i was wondering is there a way to add to the code to automatically rename the workbook as the worksheet name when this code is run?


Sub Copy_Sheet_New_Workbook()
ActiveSheet.Copy
EndSub
 
Last edited:

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Code:
Sub Copy_Sheet_New_Workbook()
    Dim WS As Worksheet
    
    Set WS = ActiveSheet
    Application.Workbooks.Add
    WS.Copy ActiveSheet
    ActiveWorkbook.SaveAs FileName:=CurDir & "\" & WS.Name
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,157
Messages
6,129,195
Members
449,493
Latest member
JablesFTW

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