excel中使用vba功能的方法图3
vba使用步骤4:在打开的模块中,我们输入如下的代码:
const Price As Single = 12.5
Sub 计算销售额()
Dim sh As Worksheet
Set sh = Worksheets("sheet1")
Dim n As integer
n = 2
Do
sh.Cells(n, 3) = sh.Cells(n, 2) * Price
n = n + 1
Loop Until sh.Cells(n, 2) = ""
End Sub