|
When you work with Microsoft Excel, you usually select a cell or cells and then perform an action, such as formatting the cells or entering values in them. In Visual Basic, it is usually not necessary to select cells before modifying them. For example, if you want to enter a formula in cell b6 using Visual Basic, you don't need to select the range b6. You just need to return the Range object and then set the Formula property to the formula you want, as shown in the following example. The training video shows the Excel macro in action. Sub EnterFormula() Worksheets("Sheet1").Range("b6").Formula = "=SUM(b2:b5)" End Sub Using the Select Method and the Selection Property in Excel The Select method activates sheets and objects on sheets; the Selection property returns an object that represents the current selection on the active sheet in the active workbook. Before you can use the Selection property successfully, you must activate a workbook, activate or select a sheet, and then select a range (or other object) using the Select method. |
![]()
Custom Search
|