Excel VBA - Copy worksheet to a new workbook and rename

preview_player
Показать описание
How to copy worksheet to a new workbook in VBA?
How to save a workbook using the name of the worksheet?

Functions:
1. For Each ws In ActiveWorkbook.Worksheets
2. ws.Copy
3. ChDir "PASTE YOUR PATH HERE"
4. ActiveWorkbook.SaveAs Filename:="PAST YOUR PATH HERE\" & ActiveSheet.Name & ".xlsx"
5. ActiveWorkbook.Close

Remark: to save as "Macro-Enabled" workbook, use ".xlsm".
Рекомендации по теме
Комментарии
Автор

Omg, such a life saver!!! After hours and hours looking at various videos on this topic, I finally understand. Great explanation and simple straightforward code! THANK YOU!

VisualFrank
Автор

Thanks...found this by mistake but it was exactly what I was looking for.

Troy-Echo
Автор

nice you, explain it very well, how about if i want only the specific sheet to copy?

Cloud
Автор

Thanks for sharing this, can you help us with code where we have more sheets in workbook and form which we want to save only selected sheets in workbook and rename the sheets.

shabarilucky
Автор

I have two sheets ("Control" and "Update") that i would like to not be copied to the folder path.
Is it possible to exclude worksheets from the copy?

PappaG
Автор

Compile error t Sub CopySheet()

why ? Can u help me?

Babah_Ale
Автор

How to save as pasted values? Please help

singhhimmattoor