Finance

Charts

Statistics

Macros

Search

A Bit About Cell Referencing with Excel VBA

On the active worksheet, one cell is always active (highlighted with a black border). You can move between cells using either the mouse or the arrow keys. Each cell on the active worksheet is identified by its address (or cell reference), which consists of the column letter and the row number, for example, A1. This type of referencing is called the A1 style.

MS Excel also supports another referencing system, known as the R1C1 style, where both rows and columns are numbered. In this system, for instance, the active cell with the address R4C3 means “row 4, column 3.” This style is often used when writing VBA programs.

To change the referencing style, go to the File tab, select Options, and in the Excel Options window choose Formulas on the left. Then, in the Working with formulas section, check or uncheck the box R1C1 reference style.

Another way to reference a cell is by its name.

 

The name or address of the active cell is shown in the Name Box (located on the left edge of the formula bar). To assign a name to a cell or range, select the desired range, go to the Formulas tab on the Ribbon, and in the Defined Names group choose Define Name. When creating names, keep in mind:

  • Names must begin with a letter or an underscore (_).
  • Instead of spaces or hyphens (-), use underscores (_) or periods (.).
  • Names should be short and must not resemble cell references like A1 or R1C1.

A cell on an inactive worksheet is identified by the sheet name followed by the cell address, for example: Sheet2!A1 (note that the exclamation mark is required). However, referencing by name is absolute, meaning when you refer to a named cell on another sheet, you don’t need to specify the sheet name.

A cell in an Excel worksheet can contain different types of information: text, numbers, or formulas. In addition, each cell can be formatted independently, and formatting options do not affect the actual content of the cell.

When entering data, Excel automatically recognizes the data type. Input is always placed in the active cell. As soon as you type a character, the content immediately appears in the formula bar, along with three buttons used for handling cell content.

To confirm data entry, press Enter, click the checkmark button in the formula bar, or press a cursor-control key.

If the entered text is longer than the cell width, it will either spill over into adjacent empty cells or be cut off at the right edge.

The content displayed in the cell may differ from what is shown on the screen—the actual value is always fully represented in the formula bar.

To edit cell content, activate the cell and press F2, or click in the formula bar.

If you don’t want Excel to automatically assign a format to your entry, type an apostrophe (‘) before the data.

0 0 votes
Évaluation de l'article
S’abonner
Notification pour
guest
0 Commentaires
Le plus ancien
Le plus récent Le plus populaire
Online comments
Show all comments
Facebook
Twitter
LinkedIn
WhatsApp
Email
Print
0
We’d love to hear your thoughts — please leave a commentx