VBA – Selection

Selection

Selection is a method in Excel VBA that performs an action. You use the Select method to select a single cell or a range of cells.

As an example, the following macro selects a range on the active worksheet. So, open your Editor Window and type in the following macros:

VBA - Selection

Fig 2.0: Selecting a group of cells

VBA - Selection

Fig 2.1: Selected group of cells

You can actually do a lot of stuffs with the selected range, like populating or inputting values into the selected group of cells, copying its value, getting the number of the selected cells, adjusting the range size (i.e. increasing or decreasing the Rows and or the Columns).

As an example, we will prompt the user to input value of any type, then we will populate a group of cells with the inputted value.

VBA - Selection

Fig 2.2: Macros for the .Select method

Fig 2.3: input box

VBA - Selection

Fig 2.4: Populating a group of Selected Cells

However, Select method can also be used to select a single cell.

Next Section: Formatting

Was this article helpful?

Related Articles

Leave a Reply