VBA Flashcards

1
Q

What is a object in programming?

A

In programming an object is a noun. A noun defines a something like a car. You can also have objects within objects so you can have a car as an object and a person within the car as another object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a property in programming?

A

A property in programming is an attribute or an adjective in real life. For example, a car can be red or a person can be tall or short. A property just describes something about the noun/object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a method in programming?

A

A method is programming is like a verb. The method describes something the object does. Running a program is a method, opening/closing a window is a method. For example, car.drive would be considered a method since it causes the object the car to do something or perform an action.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you write syntax in VBA?

A

You write the syntax differently from the English language. Instead of saying kick the ball, you would say Noun.verb or Object.method or ball.kick. For example: dinner.eat, car.drive, workbook.open, worksheet.activate.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are some examples of objects in Excel?

A

Worksheets, Cells, Workbooks

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are collections in Excel?

A

A collection is a series of objects, for example all worksheets or all cells or all workbooks. All cars is an example of a collection or grouping.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you identify items in a collection?

A

You can use an index number. This is not the best way though. For example, you can say ball(1).kick or ball(2).kick to identify different objects in a collection. A better method, however, is to use the name of the object, like, balls(soccer).kick. That means that you will always kick the right object no matter where its position is in the collection.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a parameter?

A

A parameter in programming is great. It acts like an adverb in the English language. It describes more about the verb. He drove fast. Fast is the adverb to drove. In programming you would say Balls(“Soccer”).kick:Right. This would kick the soccer ball rightward. You can leave off the adverb if the default direction is right.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you add parameters in Excel?

A

Shapes.addshape Left:=10, Top:=20, Width:=30, Height:=15. Do not use shortcuts such as shapes.addshape 10,20,100,15 because it is bad code form since most people will not remember which is which.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you activate the developer tab?

A

Go to File> Options > Customize Ribbon> Check Developer Tab

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you create a message box?

A

?msgbox(“This is a message box.”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the immediate box?

A

The immediate box can run code immediately, as a test, without running a macro.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the Locals box good for?

A

The locals box is useful for debugging and error handling.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How to write comments on your code?

A

To write a comment just put a single quote ‘ then write your comment. The program will not execute anything on that line. Example: ‘This is a comment.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How to start a Macro?

A

You start a macro by writing Sub > the macro name.

Example: Sub FirstMacro( ). Excel will automatically end the sub by inserting End Sub a few lines down.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do you run a VBA Macro?

A

You would go to the Developers Tab > The Visual Basic Editor > Create the Macro > Hit the Play Button in the top Bar

17
Q

How to Select a Range in VBA?

A

Sub FirstMacro( )
Range(“A1:A15)” = 15
Range (“g9”) = 150
End Sub

18
Q

In what direction does Excel execute code?

A

Excel executes code from the top to the bottom. In the same way we read. This is important especially when performing calculations to understand what will be executed first and then second.

19
Q

What does this code do?

Range (“A1, F10”) = 1000

A

This code will place 1000 in cells A1 and F10, but not in the cells as a range. To select cells in a range, you must insert a colon between the cell numbers. You could also do something like this: (A1:F10, F15). This would do a range and include one other cell.

20
Q

How do you add text to a cell?

A

Sub My_Text( )
Range(“A1”) = “Alison”
End Sub
All text must be surrounded by quotes.

21
Q

What is a name range?

A

A name range is a way to highlight a group of cells that you choose. If you want to select/highlight 10 rows down to 5 letter across, you would select it then go to the box at the top write which shows the cell number and click into it. Then you would be able to name this range anything. Afterwards, you would click into the same box to select your name range which would highlight all of the cells that you chose.

22
Q

How would you use a name range in VBA macro?

A

You could insert your name range right into a macro. For example, you could choose to set all cells in your name range to 10.
You would name the macro> Sub my_Named_Range( ),
type and insert the name of your name range Range(“my_table”) = 10,
then close macro with End Sub.

Sub my_Named_Range( )
Range(“my_table”) = 10
End Sub

23
Q

What does range( ).column and range( ).row do?

A

.column will return the column #, not letter that it selected.

.row will return the row # that is selected.

24
Q
What does 
Sub select_group( )
Range ("A1").select
End Sub
perform?
A

This just selects the cells in your range. This is a method since it performs an action.

25
Q

What does Range( ).Count function do.

A

This function will count the # of cells in a range. It is not like the Count function in excel or =count. The count function for a worksheet is called WorksheetFunction.Count.

26
Q

What does range( ).forumla do?

A

It will create a formula for the range that is selected in parenthesis.

27
Q

When you have double quotes inside of a number format how do you ignore it when running a macro?

A

If you have a double quote inside of a function, use another set of quotes to get Excel to ignore it. Example: “” It “”