The Select method

Use the Select method to select a range of cells. The following statement selects a range on the active worksheet:

Range("Al:C12").Select

Before selecting a range, make sure that you've activated the range's worksheet; otherwise, you get an error or the wrong range is selected. For example, if Sheet1 contains the range you want to select, use the following statements to select the range:

Sheets("Sheet1").Activate Range("A1:C12").Select

Contrary to what you may expect, the following statement generates an error. In other words, you must use two statements rather than just one: one to activate the sheet and another to select the range.

Sheets("Sheet1").Range("A1:C12").Select 'Error when Sheetl is not active

If you use GoTo method of the Application object to select a range, you can forget about selecting the right workbook/worksheet first:

Application.Goto Sheets("Sheet1").Range("A1:C12")

0 0

Post a comment