Examples of how to select cells manuallyTo manually select all the data in a column, select the first cell, and press CTRL+SHIFT+DOWN ARROW.
Likewise, to manually select a row and all columns attached to the row, press CTRL+SHIFT+DOWN ARROW+RIGHT ARROW. However, all data must be contiguous (that is, you cannot have blank rows or columns). Also, you can select the current region of data (contiguous data, with no blank rows or columns) by doing the following:
- On the Edit menu, click Go To.
- In the Go To dialog box, click Special.
- In the Go To Special dialog box, click Current region, and then click
Note If you try to record this procedure by using the macro recorder, you do not receive the same results.
Examples of how to use Visual Basic code to select cells in a rangeMicrosoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. The following Visual Basic code samples show you how to select varying ranges.
If you know the beginning cell (in this example, the beginning cell is cell C1), and you want to select down to the last cell (in the same column) that has data but do not know that address, use the following code:
If your data begins in cell C1, but is not contiguous in that column, use the following macro in Microsoft Office Excel 2003 and in earlier versions of Excel:
For additional information about how to select ranges with Visual Basic for Applications (and for more advanced examples), click the following article number to view the article in the Microsoft Knowledge Base:
Article ID: 291304 - Last Review: Jan 31, 2007 - Revision: 1