Useful Excel Template Building with VBA Range Methods and Objects!



Learn practical code now!

Begin using this code immediately in the workforce! This tutorial will guide you through the use of ranges and how to extract values from cells and input values into cells.

In this tutorial you will learn the basics of:

Watch the Video for step by step instructions.



Copy and paste this code to get you started.

Option Explicit
'Range Object
'What is an object
'Quick Intro to Integer Variable

Sub my_range()
    Range("A5").Value = 158
    Range("A6").Value = "Hello World"

    Dim my_cool_int As Integer

    my_cool_int = Range("A5").Value

    Range("D10").Value = my_cool_int

    Range("A1:D4").Value = 0

End Sub</code>


Use Range to return a Range object that represents a single Excel cell or a range of cells. Once a Range object is created, you can extract data from cells or input data into cells with ease.

There are many other types of options for Range objects as well; such as, making it bold, italics, changing font style or size, or even locking the cell for example.</P


Visual Basic is an Object-Oriented (OO) language. What is an object? An object is just as it sounds, only in a coded language. A television is an object, a basketball is an object, and a car is an object.

Objects have methods and properties (sometimes referred to as attributes).

A method is a “do something” action. Turn the television on, change the station, set a timer, or change input methods are examples of methods of an object.

Objects have _attributes_¬†as well. An attribute is asking the object, “what color are you,” or, “how tall are you, ” or things such as, “how many miles can you run,” or “what are you holding on to?”

Using Objects

Properties of objects are referenced through the “dot” operator. Simply type the name of the object and an actual “dot” after it.

Example, a Television object might have a property such as my_TV._ReturnChannel; where my_TV is a television object and _ReturnChannel is a property of that object. The properties name is “Return_Channel.”

my_TV._SetVolume might be a television object called my_TV and a method _SetVolume that actually sets the televisions volume.

Thank you for watching this tutorial. Stay tuned for more VBA tutorials.

Click the Link Below if you want to host or check out the books!

comments powered by Disqus