Cells

 

So far we have used the Range object to place values into cells or read values from cells. Instead of the Range object, you can also use Cells. For example, Cells(4,2).value is the same as Range("B4").value. Cells(4,2).value corresponds to the value of the cell with rownumber 4 and columnnumber 2, which is cell B4.

Place a command button on your worksheet and add the following code line:

Cells(4, 2).Value = 100


Result when you click the command button on the sheet:

Cells Result

You might wonder why you would use Cells, if you could use the more common Range object. That is because using Cells is particularly useful when we want to loop through ranges.

Did you find this information helpful? Show your appreciation, vote for us.

Go to Top: Cells    |   Go to Next Topic: Loop

Learn more about cells, Login to the right >>
100 easy to follow Excel VBA examples. Limited time-offer: $39.00 but only $29.00. Ends on 29th February.