VBA Flashcards
What is a object in programming?
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.
What is a property in programming?
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.
What is a method in programming?
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 do you write syntax in VBA?
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.
What are some examples of objects in Excel?
Worksheets, Cells, Workbooks
What are collections in Excel?
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 do you identify items in a collection?
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.
What is a parameter?
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 do you add parameters in Excel?
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 do you activate the developer tab?
Go to File> Options > Customize Ribbon> Check Developer Tab
How do you create a message box?
?msgbox(“This is a message box.”)
What is the immediate box?
The immediate box can run code immediately, as a test, without running a macro.
What is the Locals box good for?
The locals box is useful for debugging and error handling.
How to write comments on your code?
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 to start a Macro?
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.