0% found this document useful (0 votes)
12 views3 pages

AIS (Lab) - Prelims Terminologies

The document provides an overview of basic VBA terminologies and concepts, including macros, variables, and control structures. It explains key elements such as procedures, functions, loops, and error handling, along with examples for clarity. Additionally, it covers important terms related to VBA programming, including data types and methods for manipulating Excel objects.

Uploaded by

sarahvillar0912
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views3 pages

AIS (Lab) - Prelims Terminologies

The document provides an overview of basic VBA terminologies and concepts, including macros, variables, and control structures. It explains key elements such as procedures, functions, loops, and error handling, along with examples for clarity. Additionally, it covers important terms related to VBA programming, including data types and methods for manipulating Excel objects.

Uploaded by

sarahvillar0912
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Basic VBA Terminologies 27. Find – A method to search for a value in a range (Range("A1:A10").Find("Value")).

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")

23. Workbook – A file in Excel that contains one or more worksheets.

24. Worksheet – A single sheet within a workbook.

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.

Dim ws As Worksheet With Range("A1")


For Each ws In ThisWorkbook.Sheets .Value = "Hello"
MsgBox ws.Name .Font.Bold = True
Next ws .Font.Color = vbRed
End With

15. Do...Loop – A loop that runs until a condition is met.


23. Application.ScreenUpdating = False – Speeds up the macro by preventing screen flickering.
o Example:
Dim x As Integer
x=1
Do While x <= 5 Application.ScreenUpdating = False
Cells(x, 1).Value = x ' Code that changes a lot of things in Excel
x=x+1 Application.ScreenUpdating = True
Loop
24. Application.Calculation = xlCalculationManual – Turns off automatic recalculations to speed
16. While...Wend – Another way to write loops, but Do While...Loop is preferred. up the macro.
o Example:
Dim y As Integer
y=1 Application.Calculation = xlCalculationManual
While y <= 5 ' Run heavy calculations
Cells(y, 1).Value = y Application.Calculation = xlCalculationAutomatic
y=y+1
Wend
25. ThisWorkbook – Refers to the workbook where the macro is stored.
o Example: ThisWorkbook.Save
26. ActiveWorkbook – Refers to the currently active workbook.
o Example: ActiveWorkbook.Close
27. ActiveSheet – Refers to the currently active worksheet.
o Example: ActiveSheet.Name = "New Name"
28. Cells & Range – Used to reference cells.

Cells(1, 1).Value = "A1"


Range("B2").Value = "B2"

29. Worksheets & Sheets – Used to reference a worksheet.

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"

You might also like