, , -, VBA, . -, VBA, . - , -.
-:
Function Name ([ Arglist ]) [As Type]
VBA Statements
[ Name = expression ]
End Function
Function , .
Name . , VBA.
Arglist , .
Type . , , -, Variant.
Name = expression , , . , -.
End Function , .
(, Now, Date) .
- , , , - , , - Function End Function.
. - , . Arglist , VBA.
, , . . Excel, , .
- , _,
Cells(i, 3) = (Cells(i, 2)),
, , Excel B3÷B6 (Cells(3, 2) B3 ..).
Cells(i, 4) = Cells(i, 2) + Cells(i, 3)
_.
Sub _()
Sheets("1").Select
Dim i As Integer
i = 3
Do While Cells(i, 1) <> ""
Cells(i, 3) = (Cells(i, 2))
Cells(i, 4) = Cells(i, 2) + Cells(i, 3)
i = i + 1
Loop
End Sub
Function ( As Double) As Double
Dim As Double, As Double
= * 0.05
If > 5000 Then
= 0.01 * ( - 5000)
= +
|
|
End If
If > 10000 Then
= 0.02 * ( - 10000)
= +
End If
If > 15000 Then
= 0.03 * ( - 15000)
= +
End If
=
End Function
VBA - Variant. . - .
2
1. Excel 1 , , , _, - . .
2. 1, . . .
3. _. .
4. , , , . , .
5. End Sub _.
6. 2 3 , 1 , ( ).
7. _2, IfThen Select Case. _ _2. , . _ .