Attribute VB_Name = "Module1" Private Function ItseisarvojenErotus(ByVal Luku1 As Long, _ ByVal Luku2 As Long) As Long 1 Dim Luku1Abs As Long 2 Dim Luku2Abs As Long 3 Luku1Abs = Abs(Luku1) 4 Luku2Abs = Abs(Luku2) 5 ItseisarvojenErotus = Abs(Luku1Abs - Luku2Abs) End Function Private Function Satunnaisluku() As Long 1 Randomize 2 Satunnaisluku = Int(Rnd * 21) - 10 End Function Public Sub TeeSatunnaisOtos() 1 Dim Rivi As Long 2 Dim L1 As Long 3 Dim L2 As Long 4 Dim L3 As Long 5 Application.ScreenUpdating = False 6 Application.Calculation = xlCalculationManual 7 For Rivi = 1 To 1000 8 L1 = Satunnaisluku 9 L2 = Satunnaisluku 10 L3 = ItseisarvojenErotus(L1, L2) 11 ActiveSheet.Range("A" & Rivi).Value = L1 12 ActiveSheet.Range("B" & Rivi).Value = L2 13 ActiveSheet.Range("C" & Rivi).Value = L3 14 Next Rivi 15 Application.ScreenUpdating = True 16 Application.Calculate 17 Application.Calculation = xlCalculationAutomatic End Sub