Entering Data in a Worksheet

The information entered in a worksheet can be text, numbers, or formulas. To enter data in a cell or range of cells, you can use any of the two properties of the Range object: the Value property or the Formula property.

Value property:

ActiveSheet.Range("A1:C4").Value = "=4 * 25"

Formula property:

ActiveSheet.Range("A1:C4").Formula = "=4 * 25"

In both examples shown above, cells A1:C4 display 100—the result of the multiplication 4 * 25.

To render this into VBA: Enter this in the Immediate window:

Enter in cell A5 the following text: Range("A5").Formula = "Amount Due"

"Amount Due".

Enter the number 123 in cell D21. Range("D21").Formula = 123

Range("D21").Value = 123

Enter in cell B4 the following formula: Range("B4").Formula = "=D21 * 3" =D21 * 3_

0 0

Post a comment