Cells and ranges manipulation

Range and Cells objects are used to manipulate Excel ranges and cells. These objects have many useful properties and methods that can affect the content and formatting of individual cells or ranges within a worksheet, whether the active ones or those which we explicitly specify. VBA allows you to manipulate individual cells, ranges or named ranges …

Selection of the range is performed when first we enter range size within brackets, and further choose Select method. Properties of the selected range are changed with help of Selection object.

ActiveSheet.Range(“A1:C7”).Select
Selection.Font.Bold = True

If we want to change the color of the font, we can use the RGB function to select the desired color from the RGB scale so that it is changed by giving the value to the Color property:

ActiveSheet.Range(“A1”).Select
Selection.Font.Color = RGB(255, 0, 0)

With the CurrentRegion property, we can select the currently selected range. The Copy and Paste methods are used to copy content to the desired location.

ActiveSheet.Range(“A1”).Select
ActiveCell.CurrentRegion.Copy
ActiveSheet.Range(“A2”).Select
ActiveSheet.Paste

As said before, the Cells object allows you to assign a value to the specified cell.

ActiveSheet.Cells (1, 1) = 10