# 16.11 VBAचा सराव

Source: https://ravindrabagale.com/mr/excel/ch16-practice-exercises-with-answer-hints/16-11-module-12-macros-and-vba.html
Language: mr (Marathi with English technical terms)

आधी स्वतः करून पाहा. अडल्यावर hint उघडा. Formulaचा result sampleच्या दोन-तीन rowsवर हाताने तपासा.

Exercise 1: Header bold/green macro record; दुसऱ्या sheetवर run.
Hint आणि तपासणी
Developer Record Macro, .xlsm save. Absolute cells असूनही unqualified sheet active असू शकते—target स्पष्ट करा.

Exercise 2: Last used key row MsgBoxमध्ये.
Hint आणि तपासणी
lastRow = ws.Cells(ws.Rows.Count,"A").End(xlUp).Row

ws Set करा; no-data guard.

Exercise 3: City column trim.
Hint आणि तपासणी
For loopमधून validated text values; formula/error skip. VBA Trim टोकांचे spacesच काढतो; internal repeated spacesसाठी WorksheetFunction.Trim.

Exercise 4: Cancelled rows काढा.
Hint आणि तपासणी
फक्त disposable copyवर bottom-up For r=lastRow To2 Step−1. आधी count, नंतर reconciliation.

Exercise 5: Sheet names नवीन sheetवर list करा.
Hint आणि तपासणी
For Each ws In ThisWorkbook.Worksheets. Output sheet add झाल्यामुळे ती स्वतः listमध्ये येणार का ठरवा; existing sheet overwrite नको.

Exercise 6: GSTAmount(amount,rate) UDF, दोन decimal places.
Hint आणि तपासणी
Return amount*rate rounded2. VBA Round banker’s rounding वापरतो; worksheet ROUNDशी behavior वेगळा असू शकतो. Requirementनुसार WorksheetFunction.Round वापरा. Rate18%=0.18.

Exercise 7: Missing Orders sheetसाठी error handler.
Hint आणि तपासणी
On Error GoTo ErrHandler; meaningful message आणि shared cleanup path. Whole macroवर Resume Next नको.

रवींद्र बागले यांची tip

F8/Localsने debug करा. Macro बदल Undoने परत येतील यावर अवलंबून नको; backup copyवर test करा.
