Attribute VB_Name = "Module1" Private Sub TeeDataa() Dim Rivi As Long For Rivi = 2 To 40 Range("A" & Rivi).Value = Int(Rnd(1) * 20) Range("B" & Rivi).Value = Int(Rnd(1) * 2) + 1 Range("C" & Rivi).Value = Int(Rnd(20) * 20) - 10 Next Rivi End Sub Private Sub KaavatDSarake() 1 Dim Rivi As Long 2 Rivi = 1 3 Do While ActiveSheet.Range("A" & Rivi).Value <> "" 4 If ActiveSheet.Range("B" & Rivi).Value = "1" Then 5 ActiveSheet.Range("D" & Rivi). _ FormulaR1C1 = "=RC[-3]+RC[-1]" 6 ElseIf ActiveSheet.Range("B" & Rivi).Value = "2" Then 7 ActiveSheet.Range("D" & Rivi). _ FormulaR1C1 = "=RC[-3]-RC[-1]" 8 End If 9 Rivi = Rivi + 1 10 Loop End Sub