1/109
Looks like no tags are added yet.
What does VBA stand for?
Visual Basic for Applications.
What is VBA?
Microsoft's programmatic way to automate operations in its applications.
Which Microsoft applications support VBA?
Excel, Access, Word, PowerPoint, and Outlook.
What language is VBA derived from?
Visual BASIC (Visual Beginner's All-purpose Symbolic Instruction Code).
Are VB and VBA the same?
No. VBA is a subset of the functionality available in VB.
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.
What does it mean that Excel exposes its object model to VBA?
VBA can manipulate Excel's objects.
What is a macro language?
A language capable of automating sequences of commands in spreadsheet or word-processing applications.
What is a macro?
An action or set of actions that can run as many times as needed.
What kinds of tasks can VBA automate?
Recurring tasks, repetitive tasks, and macros triggered by events.
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.
What file extension is used for Excel files without VBA code?
.xlsx
What file extension is used for Excel files with VBA code?
.xlsm
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.
Why can VBA files pose a security risk?
VBA code can contain malicious code or viruses.
What should you do before opening an .xlsm file?
Know and trust its source.
What does Microsoft do by default with VBA code, according to the lecture?
Prevents VBA code from running by default.
Which menu path opens macro security settings in Excel?
File > Options > Trust Center > Trust Center Settings > Macro Settings.
Which macro security setting disables macros while displaying a notification?
Disable all macros with notification.
Does enabling macro notifications remove the need to approve each file?
No. You may still be asked before enabling VBA macros in a file.
What is a Trusted Location?
A folder whose .xlsm files (and files in its subfolders) can open without the usual macro-enabling warning.
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.
What can determine which macro security warning screen appears?
Whether the VBA editor is open.
How do you display the Developer tab in Excel?
File > Options > Customize Ribbon > Main Tabs > select Developer.
How often must the Developer tab setup be performed?
Only once, according to the lecture.
What is the Visual Basic Editor (VBE)?
A user-friendly integrated development environment (IDE) where programmed instructions are maintained.
What is an IDE?
A software application suite that consolidates tools required to write and test software.
What keyboard shortcut opens the VBE?
Alt + F11.
What is another way to open the VBE?
Click Visual Basic under the Developer tab.
What are the four major windows of the Visual Basic Editor?
Project Explorer Window, Properties Window, Code Window, and Immediate Window.
What is the Immediate Window useful for?
Issuing one-line VBA commands.
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.
What does a question mark at the beginning of an Immediate Window expression do?
Prints/evaluates the expression result in the Immediate Window.
What is a line of code?
A logic statement that performs a portion of a task.
How is a macro organized in VBA?
As a set of logically related lines of code that accomplishes one specific task.
What is a module?
A container used to organize code.
What is a project?
A group of all modules, forms, and other programming elements.
How many VBA projects are there per workbook?
One project per workbook.
What is a Workbook Module?
A module with code for workbook-level (file) events.
What is a Worksheet Module?
A module with code tied to worksheet events, such as selecting a range or entering a value.
What is a Standard Module?
A module that holds programmer-created macros or macros generated by the Macro Recorder.
What is a UserForm Module?
A module for dialogs that collect user input through controls such as buttons, list boxes, and checkboxes.
What is a Class Module?
A module that allows programmers to create customized objects with attributes and behaviors.
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.
Where do you rename a module?
Select the module and change its Name property in the Properties Window.
What character must a module name start with?
A letter.
What is the maximum module-name length?
255 characters.
Which characters are prohibited in module names?
Spaces, periods, exclamation marks, @, &, $, and #.
Can a module name be a reserved word?
No.
How do you delete a module?
Right-click the module and choose Remove, or select it and use File > Remove Module.
What is the Object Browser for?
Browsing available objects in the project.
What shortcut opens the Object Browser?
F2.
What menu command opens the Object Browser?
View > Object Browser.
How can you view macro code?
Select the module/macro and press F7, or use View Code in Project Explorer.
How do you protect VBA project code from viewing?
Use VBAProject Properties > Protection, lock the project for viewing, and set a password.
When does VBA project password protection take effect?
After saving and reopening the file.
Why is Hello World commonly used as a first program?
It is a traditional simple output exercise for learning a language and environment.
What filename is used for the Hello World VBA exercise?
HelloWorld.xlsm.
What module name is used in the Hello World exercise?
Hello.
What is the macro name in the Hello World exercise?
PrintHello.
How does a VBA Sub procedure begin?
Sub ProcedureName()
How does a VBA Sub procedure end?
End Sub
What VBA statement displays Hello World in a message box?
MsgBox "Hello World"
What is the purpose of Option Explicit?
It requires variables to be declared before use.
What marks a comment in VBA?
An apostrophe (single quote).
Are VBA comments executed?
No.
What color are comments shown in the VBE?
Green.
What color are VBA keywords such as Sub and End shown in the VBE?
Blue.
What color is ordinary code shown in the VBE?
Black.
What color indicates a syntax-error line after pressing Enter?
Red.
What key runs a macro from the VBE?
F5.
What toolbar button also runs a macro?
The green play button.
Which macro is selected and run in the Hello World exercise?
PrintHello.
Why create a worksheet Run button?
To let users run a macro without opening or knowing how to use the VBE.
What menu path starts creation of a worksheet button?
Developer > Insert > Button.
Where is the button placed in the Hello World exercise?
Over cells B1 through C2.
Which macro is assigned to the Hello World button?
PrintHello.
What text is displayed on the Hello World button?
Print Hello Message.
What naming style is recommended for VBA keywords?
Start keywords with a capital letter, such as Sub and End.
What naming style is recommended for variables?
Start variable names with a lowercase letter, such as firstName.
What coding practice is emphasized for making VBA code easier to read?
Indentation is important.
Which key opens VBA documentation help?
F1.
What does IntelliSense do?
Provides hints and tries to complete certain words in the VBE.
What may the VBE insert after entering the first line of a Sub?
A pair of parentheses and an End Sub line.
How does IntelliSense help with Dim statements?
It helps choose a variable type.
How does IntelliSense help with objects?
It lists available properties and methods.
How does IntelliSense help with methods?
It lists the arguments.
Which shortcut invokes variable-name autocomplete?
Ctrl + Space.
What file is used for the car-sales exercise?
Car Sales.xlsx, saved as Car Sales.xlsm.
What Sub name is used for the car-sales program?
CountHighSales.
Which variables are declared Integer in CountHighSales?
i, j, and nHigh.
What type is cutoff declared as?
Currency.
What does Dim do in VBA?
Declares a variable and its data type.
What does InputBox ask for in CountHighSales?
The sales value (cutoff) to check.
What is the exact InputBox prompt in CountHighSales?
What sales value do you want to check for?
What does For j = 1 To 6 loop through?
Six regions.
What does For i = 1 To 36 loop through?
Thirty-six months for the current region.
Why is nHigh = 0 inside the outer loop?
To reset the count for each new region.
What condition identifies a qualifying sales value?
wsData.Range("Sales").Cells(i, j) >= cutoff
What does >= mean?
Greater than or equal to.