Using offset, activecell and inputbox features | |
Automatic calculations and easy data entry using a macro: | |
| Sub test() Dim price, qty, amount As Single Range("A1") = "Item" Range("B1") = "UnitPrice" Range("C1") = "Quantity" Range("D1") = "Amount" ActiveCell.Offset(1, 0).Range("A1").Select ActiveCell = InputBox("Enter the name of item") ActiveCell.Offset(0, 1).Range("A1").Select price = InputBox("Enter the price") ActiveCell = price ActiveCell.Offset(0, 1).Range("A1").Select qty = InputBox("Enter the qty") ActiveCell = qty ActiveCell.Offset(0, 1).Range("A1").Select amount = price * qty ActiveCell = amount ActiveCell.Offset(1, -3).Range("A1").Select ActiveCell.Offset(-1, 0).Range("A1").Select End Sub |
|