VBA Select Range or Cells in Excel – Excel VBA Automation

VBA Select Range
  • Save

Introduction/Problem Statement

When we work with excel, many times we want to VBA select range or cell in a worksheet. Here below, we have shared many ways to manipulate the selected range easily.

Solution:

Select a single cell:

This code will select the cell A4 in the given worksheet. This code only works if sheet1 is active sheet if sheet1 not active then it shows error.

Select a single cell
  • Save

If we want to select a sheet that is not an active sheet, then first we need to activate that sheet. This code will select the range A2 of sheet2.

Activate Sheet
  • Save

Select a range of cells of the Active Sheet:

This code will select the range (“A2:B20”) of the active sheet.

Select a range of cells of active sheet
  • Save

Select a Range of Non-Contiguous Cells:

We can select a group of cells that are not next to each other. This code will select cells A2,A4,D4 in the active sheet.

Select a Range of Non-Contiguous Cells
  • Save

Select All the Cells in a Worksheet

This Code will select all cells of the worksheet.

Select All the Cells in a Worksheet
  • Save

Select a Named Range in Excel:

This code will select “Name” range cells. But before using this code user must define a named range in “Name Manager”.

Select a Named Range in Excel
  • Save

Manipulating the Selection Object

We can easily manipulate the selected cells. This code will select the range A2:D10 and change the background color to red.

Manipulating the Selection Object
  • Save

Conclusion:

If you want to VBA Select Range or cell in a worksheet then you can use any code shown above(according to need). This code will very useful if you want to manipulate the selected range.

Don't miss out!
Subscribe To Newsletter

Get the latest Excel, VBA, Automation, Tips & Tricks, delivered straight to your inbox.

Invalid email address
Give it a try. You can unsubscribe at any time.

Leave a Reply

Your email address will not be published. Required fields are marked *

Copy link
Powered by Social Snap