Using the active cell

The active cell is just the current cell - wherever you move to, or click on, in the worksheet. The way to address the active cell is, not surprisingly:

ActiveCell

A cell has lots of properties - a font, value, a formula, background color and so on. Here are some of the more important properties:

ActiveCell.Value - The simple text or number or date of a cell (as it is displayed in the sheet). If the cell contains a formula, then Values displays the results of the formula. For example:

If ActiveCell.Value = "0" Then

ActiveCell.Value = "Zero" 

Else

MsgBox "Cell has value: " & ActiveCell.Value 

End If

This converts a current cell containing "0" to "zero" and displays the value of current cell if it does not contain zero.

In a similar way, the current cells formula can be determined or set using:

ActiveCell.Formula

The Formula property returns either the formula (for example "=a1 + a2") or, if the cell does not contain a formula, the value.

Here are some more properties:

ActiveCell.NumberFormat

ActiveCell.Font

(for example)

ActiveCell.Font.Bold 

ActiveCell.Font.Italic 

ActiveCell.Font.Name 

ActiveCell.Font.Size