VBA PROGRAM to convert each sheet to workbook.

Prompt : i am working in ms excel i have multiple worksheets i want to convert each worksheet to workbook and i want to store this workbook in c drive vba folder create vba program for me

๐Ÿ“Œ VBA Code: Convert Each Worksheet into Separate Workbook

๐Ÿ”น Steps to Use

  1. Press ALT + F11 โ†’ VBA Editor

  2. Click Insert โ†’ Module

  3. Paste the code below

  4. Press F5 to run

 

Sub ConvertEachSheetToWorkbook()

Dim ws As Worksheet
Dim newWB As Workbook
Dim folderPath As String
Dim fileName As String

‘ Folder Path
folderPath = “C:\VBA Folder\”

‘ Create folder if it does not exist
If Dir(folderPath, vbDirectory) = “” Then
MkDir folderPath
End If

Application.ScreenUpdating = False
Application.DisplayAlerts = False

‘ Loop through each worksheet
For Each ws In ThisWorkbook.Worksheets

‘ Copy sheet to new workbook
ws.Copy
Set newWB = ActiveWorkbook

‘ File name = Sheet Name
fileName = folderPath & ws.Name & “.xlsx”

‘ Save workbook
newWB.SaveAs fileName:=fileName, FileFormat:=xlOpenXMLWorkbook

‘ Close new workbook
newWB.Close SaveChanges:=False

Next ws

Application.DisplayAlerts = True
Application.ScreenUpdating = True

MsgBox “All worksheets converted and saved successfully!”, vbInformation

End Sub