-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScope.bas
39 lines (26 loc) · 1.04 KB
/
Scope.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
'----------------------------------------------------------------------------------------
' Module1
Option Explicit
Public num1, num2, res(7) As Integer
Sub Operate()
num1 = ActiveSheet.Range("B1")
num2 = ActiveSheet.Range("B2")
res(0) = num1 + num2
res(1) = num1 - num2
res(2) = num1 * num2
res(3) = num1 / num2
res(4) = num1 \ num2 ' no difference from '/' because of Integer / Integer
res(5) = num1 Mod num2
res(6) = num1 ^ num2
res(7) = num1 >= num2 ' why -1 when num1 = 5, num2 = 2?
End Sub
'----------------------------------------------------------------------------------------
' Sheet1
Sub ReadResults()
Dim i As Integer
For i = 0 To 7
ActiveSheet.Range("B" & 3 + i) = res(i)
Next i
' Range("B3:B10").Value = res ' why doesn't it work?
' Range("B3:B10").Value = WorksheetFunction.Transpose(res) ' it works but I want to avoid WorkSheetFunction() if possible
End Sub