

Now, you can observe, Excel automatically adds the line End Sub below the first message line when you press Enter. Step 3: Double click on it, it is also called a code window, where you need to type Sub Cells_Example1() as the first message without any quotes around it.

Step 2: To create a blank module, right-click on Microsoft excel objects, in that click on Insert and under the menu section select Module, where the blank module gets created. Step 1: Select or click on Visual Basic in the Code group on the Developer tab or you can directly click on Alt + F11 shortcut key. You can download this VBA Cells Excel Template here – VBA Cells Excel Template Example #1 – VBA Cells To select cell B4 on the active worksheet, you can use either of the following examples: Cells (5, “E”)Ĭomma (,): Separator between them is the union operator, which is used to combine several range of cells.Įxpression = Cells (4, 2) indicates it is “B4” Cell on an active worksheet in row 4 and col 2Įxpression = Cells (4, “E”) indicates it is “B4” Cell on an active worksheet in row 4 and col 2ĭifference between Cell & Range syntax VBA code Note: Either numbers or letters can be used to specify the Column index in CELLS E.G. Row Index: Which is row number which we are referring to.Ĭolumn Index: Which is column number which we are referring to. The syntax for VBA cells function in excel is as follows:Ĭells argument will consider two numeric arguments to represent row & column, where the first one is for representing row number & and the second or last one referring to as column number. This cells property is used to specify a single cell or all cells on the worksheet, where it returns a single cell in the Cells collection. The cell is a property of range in excel sheet, which is a characteristic, where it is used to describe a range Cells only returns one cell which is used to represent cells within a range of the worksheet. Difference between range & cells in VBA is Cells usually refer to a single cell at a time, while Range references a group of cells.
