12. Macros and VBA
Chala mitrano, aaj aapan Excel la "kaam karayla shikvuya" – Macros aani VBA (Visual Basic for Applications). Roj sakali tech formatting, tech trimming, tech copy-paste? Ekda macro banva aani ek button dabun kaam sampva! Macro record karne, VBA Editor, variables (चल – बदलणारे मूल्य साठवणारी जागा), loops (पुनरावृत्ती – तीच कृती पुन्हा पुन्हा करणे), practical macros, user-defined functions aani debugging – sagla step by step. Ghabru naka, code pahilyanda avghad vatto, pan ha module sampla ki tumhi swatahche macros lihal.
What you will learn in this module
- The Developer tab, Trust Center macro security and the
.xlsmformat - Recording macros with absolute and relative references; running them from a button or shortcut
- The VBA Editor: modules, Project Explorer, Immediate window
- Sub procedures, variables and data types, Range/Cells/Worksheets, MsgBox/InputBox
- If, Select Case, For, For Each and Do loops, and finding the last row
- Practical macros on our data, a delivery-fee user-defined function, On Error handling, debugging and the Personal Macro Workbook
Macro safety
Macros can run any code on your computer. Enable macros only in files you trust. Microsoft 365 blocks macros by default in files downloaded from the internet or received as e-mail attachments (the Mark of the Web). Practise on your own files. All code in this module is plain VBA for Excel on Windows; some features (Personal Macro Workbook path, ActiveX controls) differ on Mac.
Concepts in this chapter
- 12.1Developer Tab, Macro Security and .xlsm
- 12.2Recording a Macro: Absolute vs Relative
- 12.3Running Macros: Button, Shortcut and the Macros Dialog
- 12.4The VBA Editor (VBE)
- 12.5Sub Procedures
- 12.6Variables and Data Types
- 12.7Range, Cells and Worksheets
- 12.8MsgBox and InputBox
- 12.9If and Select Case
- 12.10Loops: For, For Each and Do
- 12.11Finding the Last Row (and Column)
- 12.12Practical Macros on Our Data
- 12.13User-Defined Functions: a Delivery Fee Function
- 12.14Error Handling with On Error
- 12.15Debugging: F8, Breakpoints, Immediate and Locals Windows
- 12.16The Personal Macro Workbook
The chapter recap is at the end of the last concept page.