BMGT302 - VBA Intro

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/109

encourage image

There's no tags or description

Looks like no tags are added yet.

110 Terms

1
New cards

What does VBA stand for?

Visual Basic for Applications.

2
New cards

What is VBA?

Microsoft's programmatic way to automate operations in its applications.

3
New cards

Which Microsoft applications support VBA?

Excel, Access, Word, PowerPoint, and Outlook.

4
New cards

What language is VBA derived from?

Visual BASIC (Visual Beginner's All-purpose Symbolic Instruction Code).

5
New cards

Are VB and VBA the same?

No. VBA is a subset of the functionality available in VB.

6
New cards

How does VB differ from VBA?

VB is a standalone programming language and does not need Excel; VBA is primarily used with application software such as Excel.

7
New cards

What does it mean that Excel exposes its object model to VBA?

VBA can manipulate Excel's objects.

8
New cards

What is a macro language?

A language capable of automating sequences of commands in spreadsheet or word-processing applications.

9
New cards

What is a macro?

An action or set of actions that can run as many times as needed.

10
New cards

What kinds of tasks can VBA automate?

Recurring tasks, repetitive tasks, and macros triggered by events.

11
New cards

What other functions can VBA perform?

Create custom worksheet functions; change the appearance and simplify the use of workbooks; control other Office applications from Excel.

12
New cards

What file extension is used for Excel files without VBA code?

.xlsx

13
New cards

What file extension is used for Excel files with VBA code?

.xlsm

14
New cards

What is demonstrated by the car-loan calculation application in Car Loan.xlsm?

An Excel application that uses VBA to automate a car-loan calculation.

15
New cards

Why can VBA files pose a security risk?

VBA code can contain malicious code or viruses.

16
New cards

What should you do before opening an .xlsm file?

Know and trust its source.

17
New cards

What does Microsoft do by default with VBA code, according to the lecture?

Prevents VBA code from running by default.

18
New cards

Which menu path opens macro security settings in Excel?

File > Options > Trust Center > Trust Center Settings > Macro Settings.

19
New cards

Which macro security setting disables macros while displaying a notification?

Disable all macros with notification.

20
New cards

Does enabling macro notifications remove the need to approve each file?

No. You may still be asked before enabling VBA macros in a file.

21
New cards

What is a Trusted Location?

A folder whose .xlsm files (and files in its subfolders) can open without the usual macro-enabling warning.

22
New cards

What happens when opening an .xlsm file outside a trusted location?

A macro security warning may appear and macros need to be enabled if the file is trusted.

23
New cards

What can determine which macro security warning screen appears?

Whether the VBA editor is open.

24
New cards

How do you display the Developer tab in Excel?

File > Options > Customize Ribbon > Main Tabs > select Developer.

25
New cards

How often must the Developer tab setup be performed?

Only once, according to the lecture.

26
New cards

What is the Visual Basic Editor (VBE)?

A user-friendly integrated development environment (IDE) where programmed instructions are maintained.

27
New cards

What is an IDE?

A software application suite that consolidates tools required to write and test software.

28
New cards

What keyboard shortcut opens the VBE?

Alt + F11.

29
New cards

What is another way to open the VBE?

Click Visual Basic under the Developer tab.

30
New cards

What are the four major windows of the Visual Basic Editor?

Project Explorer Window, Properties Window, Code Window, and Immediate Window.

31
New cards

What is the Immediate Window useful for?

Issuing one-line VBA commands.

32
New cards

How can the Immediate Window be used with worksheet ranges?

It can execute commands to select a worksheet range and display the address of a named range.

33
New cards

What does a question mark at the beginning of an Immediate Window expression do?

Prints/evaluates the expression result in the Immediate Window.

34
New cards

What is a line of code?

A logic statement that performs a portion of a task.

35
New cards

How is a macro organized in VBA?

As a set of logically related lines of code that accomplishes one specific task.

36
New cards

What is a module?

A container used to organize code.

37
New cards

What is a project?

A group of all modules, forms, and other programming elements.

38
New cards

How many VBA projects are there per workbook?

One project per workbook.

39
New cards

What is a Workbook Module?

A module with code for workbook-level (file) events.

40
New cards

What is a Worksheet Module?

A module with code tied to worksheet events, such as selecting a range or entering a value.

41
New cards

What is a Standard Module?

A module that holds programmer-created macros or macros generated by the Macro Recorder.

42
New cards

What is a UserForm Module?

A module for dialogs that collect user input through controls such as buttons, list boxes, and checkboxes.

43
New cards

What is a Class Module?

A module that allows programmers to create customized objects with attributes and behaviors.

44
New cards

What are two ways to insert a standard module?

Use Insert > Module in the VBE, or right-click a project item and choose Insert > Module.

45
New cards

Where do you rename a module?

Select the module and change its Name property in the Properties Window.

46
New cards

What character must a module name start with?

A letter.

47
New cards

What is the maximum module-name length?

255 characters.

48
New cards

Which characters are prohibited in module names?

Spaces, periods, exclamation marks, @, &, $, and #.

49
New cards

Can a module name be a reserved word?

No.

50
New cards

How do you delete a module?

Right-click the module and choose Remove, or select it and use File > Remove Module.

51
New cards

What is the Object Browser for?

Browsing available objects in the project.

52
New cards

What shortcut opens the Object Browser?

F2.

53
New cards

What menu command opens the Object Browser?

View > Object Browser.

54
New cards

How can you view macro code?

Select the module/macro and press F7, or use View Code in Project Explorer.

55
New cards

How do you protect VBA project code from viewing?

Use VBAProject Properties > Protection, lock the project for viewing, and set a password.

56
New cards

When does VBA project password protection take effect?

After saving and reopening the file.

57
New cards

Why is Hello World commonly used as a first program?

It is a traditional simple output exercise for learning a language and environment.

58
New cards

What filename is used for the Hello World VBA exercise?

HelloWorld.xlsm.

59
New cards

What module name is used in the Hello World exercise?

Hello.

60
New cards

What is the macro name in the Hello World exercise?

PrintHello.

61
New cards

How does a VBA Sub procedure begin?

Sub ProcedureName()

62
New cards

How does a VBA Sub procedure end?

End Sub

63
New cards

What VBA statement displays Hello World in a message box?

MsgBox "Hello World"

64
New cards

What is the purpose of Option Explicit?

It requires variables to be declared before use.

65
New cards

What marks a comment in VBA?

An apostrophe (single quote).

66
New cards

Are VBA comments executed?

No.

67
New cards

What color are comments shown in the VBE?

Green.

68
New cards

What color are VBA keywords such as Sub and End shown in the VBE?

Blue.

69
New cards

What color is ordinary code shown in the VBE?

Black.

70
New cards

What color indicates a syntax-error line after pressing Enter?

Red.

71
New cards

What key runs a macro from the VBE?

F5.

72
New cards

What toolbar button also runs a macro?

The green play button.

73
New cards

Which macro is selected and run in the Hello World exercise?

PrintHello.

74
New cards

Why create a worksheet Run button?

To let users run a macro without opening or knowing how to use the VBE.

75
New cards

What menu path starts creation of a worksheet button?

Developer > Insert > Button.

76
New cards

Where is the button placed in the Hello World exercise?

Over cells B1 through C2.

77
New cards

Which macro is assigned to the Hello World button?

PrintHello.

78
New cards

What text is displayed on the Hello World button?

Print Hello Message.

79
New cards

What naming style is recommended for VBA keywords?

Start keywords with a capital letter, such as Sub and End.

80
New cards

What naming style is recommended for variables?

Start variable names with a lowercase letter, such as firstName.

81
New cards

What coding practice is emphasized for making VBA code easier to read?

Indentation is important.

82
New cards

Which key opens VBA documentation help?

F1.

83
New cards

What does IntelliSense do?

Provides hints and tries to complete certain words in the VBE.

84
New cards

What may the VBE insert after entering the first line of a Sub?

A pair of parentheses and an End Sub line.

85
New cards

How does IntelliSense help with Dim statements?

It helps choose a variable type.

86
New cards

How does IntelliSense help with objects?

It lists available properties and methods.

87
New cards

How does IntelliSense help with methods?

It lists the arguments.

88
New cards

Which shortcut invokes variable-name autocomplete?

Ctrl + Space.

89
New cards

What file is used for the car-sales exercise?

Car Sales.xlsx, saved as Car Sales.xlsm.

90
New cards

What Sub name is used for the car-sales program?

CountHighSales.

91
New cards

Which variables are declared Integer in CountHighSales?

i, j, and nHigh.

92
New cards

What type is cutoff declared as?

Currency.

93
New cards

What does Dim do in VBA?

Declares a variable and its data type.

94
New cards

What does InputBox ask for in CountHighSales?

The sales value (cutoff) to check.

95
New cards

What is the exact InputBox prompt in CountHighSales?

What sales value do you want to check for?

96
New cards

What does For j = 1 To 6 loop through?

Six regions.

97
New cards

What does For i = 1 To 36 loop through?

Thirty-six months for the current region.

98
New cards

Why is nHigh = 0 inside the outer loop?

To reset the count for each new region.

99
New cards

What condition identifies a qualifying sales value?

wsData.Range("Sales").Cells(i, j) >= cutoff

100
New cards

What does >= mean?

Greater than or equal to.