AIS (Lab) - Prelims Terminologies
AIS (Lab) - Prelims Terminologies
1. Macro – A recorded or written set of instructions that automate tasks in Excel. 28. Replace – A method to replace values in a range (Cells.Replace "OldValue", "NewValue").
2. VBA (Visual Basic for Applications) – A programming language used to write macros in 29. Debugging – The process of finding and fixing errors in VBA code.
Microsoft Office applications.
30. Breakpoint – A stopping point in the code used for debugging.
3. Editor (VBE - Visual Basic Editor) – The environment where VBA code is written and edited.
31. Immediate Window – A tool in the VBE to run quick VBA commands and test code.
4. Module – A container in the VBE where VBA code is stored.
32. Step Into (F8) – A debugging tool that runs code line by line.
5. Procedure (Subroutine or Sub) – A block of code that performs a specific task. Declared using
Sub and End Sub. 33. Compile – The process of checking VBA code for syntax errors before running it.
6. Function – A block of code that returns a value. Declared using Function and End Function. 34. Add-ins – Extra functionalities that extend Excel's capabilities, often written in VBA.
7. Variable – A storage location in VBA used to hold data temporarily. 35. Object Library – A collection of objects, properties, and methods that VBA can use.
8. Constant – A fixed value that does not change during the execution of a macro.
9. Object – An element in Excel (e.g., Workbook, Worksheet, Range) that can be manipulated using
Variable Declaration & Data Types
VBA.
10. Property – An attribute of an object (e.g., .Value, .Font, .Color). 1. Dim (Dimension) – Declares a variable in VBA.
o Example: Dim x As Integer
11. Method – An action that an object can perform (e.g., .Copy, .Select, .Activate).
2. Integer – A numeric data type that stores whole numbers from -32,768 to 32,767.
12. Event – A trigger that runs VBA code automatically (e.g., Worksheet_Change, Workbook_Open). o Example: Dim count As Integer
3. Long – A data type that stores large whole numbers (-2,147,483,648 to 2,147,483,647).
13. Range – A selection of one or more cells in Excel, referenced as Range("A1") or Cells(1,1).
o Example: Dim bigNumber As Long
14. Loop – A structure that repeats code multiple times (For...Next, Do...Loop, While...Wend). 4. Double – A data type for decimal numbers with more precision.
o Example: Dim price As Double
15. Conditional Statement – A structure that makes decisions (If...Then...Else, Select Case). 5. Single – A data type for decimal numbers with less precision than Double.
16. Error Handling – Code to handle runtime errors (On Error Resume Next, On Error GoTo). o Example: Dim temperature As Single
6. String – A data type used for text values.
17. UserForm – A custom dialog box in VBA used for user input. o Example: Dim name As String
18. Message Box (MsgBox) – A pop-up dialog that displays a message to the user. 7. Boolean – A data type that stores True or False.
o Example: Dim isFinished As Boolean
19. Input Box (InputBox) – A dialog that prompts the user to enter a value. 8. Variant – A flexible data type that can hold any type of data (text, numbers, etc.).
20. Worksheet Function – A built-in Excel function used in VBA o Example: Dim anything As Variant
(Application.WorksheetFunction.Sum). 9. Object – A variable type used to store an object (like a worksheet or workbook).
o Example: Dim ws As Worksheet
21. ActiveWorkbook – Refers to the currently active workbook. 10. Set – Used to assign an object to a variable.
22. ActiveSheet – Refers to the currently active worksheet. o Example: Set ws = ThisWorkbook.Sheets("Sheet1")
25. Cells – A method to refer to a specific cell using row and column numbers (Cells(1,1) for A1).
26. Offset – A method to refer to a cell relative to another cell (Range("A1").Offset(1,0) refers to A2).
Control Structures (Conditions & Loops) Other Important Terms
11. If...Then...Else – A conditional statement to execute code based on a condition. 17. MsgBox – Displays a message box.
o Example: MsgBox "Hello, World!"
If score >= 50 Then 18. InputBox – Prompts the user for input.
MsgBox "Pass" o Example: userName = InputBox("Enter your name:")
Else 19. On Error Resume Next – Ignores errors and continues execution.
MsgBox "Fail" o Example:
End If On Error Resume Next
x = 1 / 0 ' This would normally cause an error, but VBA will ignore it.
12. Select Case – A cleaner way to write multiple If conditions.
20. On Error GoTo – Redirects the code to an error-handling routine.
Select Case grade
Case "A": MsgBox "Excellent" On Error GoTo ErrorHandler
Case "B": MsgBox "Good" x = 1 / 0 ' This causes an error
Case Else: MsgBox "Needs Improvement" Exit Sub
End Select ErrorHandler:
MsgBox "An error occurred!"
13. For...Next – A loop that runs a fixed number of times.
21. Exit Statements – Used to exit a loop or procedure.
For i = 1 To 10 o Exit Sub → Exits a subroutine.
Cells(i, 1).Value = i o Exit Function → Exits a function.
Next i o Exit For → Exits a For loop.
o Exit Do → Exits a Do loop.
14. For Each...Next – A loop that iterates through all items in a collection (like all worksheets). 22. With...End With – Simplifies multiple property changes for an object.
Worksheets("Sheet1").Activate
Sheets(1).Select
30. Find & Replace – Used to search for and replace values.
Cells.Find("OldValue").Value = "NewValue"
Cells.Replace "Old", "New"