Aapne kabhi socha hai ki agar aapke paas ek Excel file hai jisme kai sheets hain, aur aapko unko alag-alag files mein convert karna ho toh kya karenge? 🤔
Aaj hum aapko batayenge ki kaise ek simple VBA macro ka use karke aap apne Excel sheets ko easily alag files mein convert kar sakte hain. Yeh process bahut hi simple hai, bas aapko thoda sa coding ka knowledge hona chahiye. Is video mein aapko step-by-step process dikhaunga, aur niche code bhi diya gaya hai jo aap directly apne Excel mein use kar sakte hain. Toh chaliye shuru karte hain! 🚀Step 1: Samajhte Hain Problem Ko
Jab aapke paas ek Excel workbook mein kai sheets hoti hain aur aapko har sheet ko alag file mein save karna hota hai, toh yeh kaafi time-consuming ho sakta hai agar aap manually karte hain.
Agar aapko yeh kaam jaldi aur easily karna hai, toh VBA macros aapka best friend ban sakte hain. VBA (Visual Basic for Applications) ek programming language hai jo Excel mein built-in hoti hai aur isse aap apne tasks ko automate kar sakte hain.
Step 2: VBA Macro Ka Code Ab main aapko woh code dikhata hoon jisme ek simple macro ka use karke har sheet ko ek alag Excel file mein convert karenge. Yeh code niche diya gaya hai, aap ise apne Excel mein paste karke use kar sakte hain.
Sub SaveAllSheetsAsNewFiles()
Dim ws As Worksheet
Dim newWorkbook As Workbook
Dim saveFolder As String
Dim filePath As String
Dim folderDialog As FileDialog
' Folder picker dialog initialize karein
Set folderDialog = Application.FileDialog(msoFileDialogFolderPicker)
' Dialog show karein aur check karein ke user ne koi folder select kiya hai
If folderDialog.Show = -1 Then
' Selected folder ka path lein
saveFolder = folderDialog.SelectedItems(1)
' Active workbook ke har sheet ke liye loop
For Each ws In ActiveWorkbook.Sheets
' Har sheet ke liye ek naya workbook banayein
Set newWorkbook = Workbooks.Add
' Current sheet ko naye workbook mein copy karein
ws.Copy Before:=newWorkbook.Sheets(1)
' Sheet name ke saath file ka path aur .xlsx extension set karein
filePath = saveFolder & "\" & ws.Name & ".xlsx"
' New workbook ko specified location par save karein
newWorkbook.SaveAs filePath, FileFormat:=xlOpenXMLWorkbook
newWorkbook.Close False
Next ws
' Notify user ke process complete ho gaya hai
MsgBox "All sheets have been saved as individual files."
Else
MsgBox "No folder selected. Operation cancelled."
End If
End Sub
Step 3: Macro Ko Apne Excel Mein Add Karna
- Excel open karein aur Alt + F11 press karke VBA editor open karein.
- Insert > Module par click karein, jisse ek naya module create hoga.
- Upar diye gaye code ko is module mein paste karein.
- Alt + F8 press karke macro ko run karein.
Step 4: Code Kaam Kaise Karta Hai?
- Pehle, jab aap macro run karte hain, ek folder picker dialog open hota hai jisme aapko woh folder select karna hota hai jaha aap apne new files save karna chahte hain.
- Uske baad, macro aapke active workbook ke har sheet ko ek alag workbook mein copy karta hai.
- Har sheet ka ek naya file banaya jata hai aur woh file selected folder mein save ho jati hai.
Step 5: Manual Approach (Agar Aap Macro Nahi Use Karna Chahte) Agar aap macro use nahi karna chahte, toh aap manually bhi har sheet ko ek alag file mein save kar sakte hain:
- Sheet ko select karein.
- File > Save As par click karein.
- Sheet ka naam den aur file ko save kar dein.
Lekin yeh process manual hai aur agar aapke paas bohot saari sheets hain, toh yeh time-consuming ho sakta hai.
Step 6: Developer Tab Enable Karna Agar aapko VBA code run karna hai toh Excel mein Developer Tab enable karna zaroori hai. Agar yeh tab aapke Excel mein dikhayi nahi de raha, toh aap isse enable kar sakte hain:
- File > Options par click karein.
- Customize Ribbon select karein aur phir Developer checkbox ko tick karein.
- OK par click karein aur Developer tab aapke ribbon mein dikhayi dega.
Step 7: Macro-Enabled Excel File Save Karna Agar aap macro use kar rahe hain, toh apni file ko macro-enabled workbook ke roop mein save karein:
- File > Save As par click karein.
- Save as Type mein Excel Macro-Enabled Workbook (*.xlsm) select karein.
- Save par click karein.
0 टिप्पणियाँ