VBA Exam 1, Chapters 1-8
How must excel files containing macros be saved?
.xlsm
For variable types, double stores data as:
16 digit plus E
What is VBA?
A statistical tool developed by Microsoft for financial analysts
What is an integer?
A whole number data type
Which is not an application object property?
ActiveFile
Some useful applications object properties are:
ActiveWindow, ActiveCell, ActiveSheet, ActiveChart
Write a VBA code that counts the amount of worksheets in the current active workbook
ActiveWorkbook.Worksheets.Count
Which shortcut key gets you to VBA from Excel?
Alt+F11
A true and false variable is defined as a:
Boolean
True or False options belong to what variable types?
Boolean
What can variable names not contain?
Cannot use alphabetical characters, numbers, underscores
What is used to reference particular cells in ranges?
Cells
What is not an example of a property in the excel object model?
Copy
What does the following VBA code do? Dim Invoices as Range Set Invoices = Range("A1:A15")
Defines the variable "Invoices" as a range and sets the range of Invoices to be from A1:A15
What word do you use to declare variables?
Dim As
What is the code needed to use a variable for a range name
Dim rngName As String rngName="Sales" MsgBox Range(rngName) address
What does "MsgBox Range ("A1").Value" do?
Displays the value of cell A1 in a message box
Control logic and loops can be translated into code by Recording a Macro
False
The attributes of a property are called objects
False
VBA is the same as VB
False
Which is not a method in excel's object model?
Formula
What is not an accepted variable naming convention?
Henderson-taxRATE
What does Workbooks Collection consist of?
Individual Workbook Objects
Sort
Is not a property of a range
Why do we use option explicit?
It ensures that we define our variables
What does this code mean "R[4]C[2]:R[1]C[1]
It is a relative referencing
What is intellisense?
It is a way to help you get the syntax and spelling of the code right
What does this code mean R4C2:R1C1
It is an absolute reference
What does "Dim firstName As Strong" represent?
It represents that we have created a variable which implies that it requires a strong of text
What is the best way to end a Do while loop?
Loop
What is a unit of VBA code called?
Macro
A macro feature you cannot specify is:
Macro paramenters/limits
Do single line IF statements need an End if statement?
No
What does a for loop do?
Performs an action for a specific number of times
Where can you store macros so that they are always available no matter which workbook is open?
Personal Macro Workbook
These are all good programming practices
Provide sufficient comments, indent consistently, break long lines into multiple lines
Write code to find the average in cell "A19" and bold it
Range("A19").Value="Average" Range("A19").Font.Bold= true
What code would you use to enter the word "Grapes" into cell B4?
Range("B4").Value="Grapes"
How do you write a conditional statement that has its own line of code depending on the condition in one line of code?
Single-line IF statement: IF condition THEN statement [Else statement2]
What type of error can you come across in debugging your code?
Syntax, Logic, Runtime
What is a subroutine?
The logical section of code that performs a particular task
What is not true about worksheet level ranges?
They cannot be referenced into from different sheets
What is the advantage of declaring variables using the 'Dim' statement?
To specify the variable type such as integer, string, currency, variant
A variable is a place to store a piece of information
True
An infinite loop can occur if you run a do until loop (do [until condition] [statement]loop) that never satisfies the condition that is set and does not have an exit do
True
In an If-Then-Else-End if statement the Else is optional
True
Methods are things you can do to or with an object
True
Business problems can be modeled in Excel using...
User inputs, Formulas used to relate values, and Outputs calculated
What does VBA stand for?
Visual Basic Application
Write a line of code that change the font of range A3:C10 on worksheet "Data" to bold
Worksheets("Data").Range("A3:C10").Font.Bold=True
Is it possible to create new worksheets in a workbook using code?
Yes
What is the code in order to automate the process of finding out what 10+9+8+7+6+5+4+3+2+1 is using a FOR loop?
dim i as integer dim j as integer for i= 1 to 10 for j= i+j next i
Subroutine
the logical section of code that performs a particular task
How do you write a comment?
use '