Public x1 As Variant ` Program fukcja_kw2.xls - liczy pierwiastki
Public x2 As Variant ` Makro1_liczy_x1_x2 w funkcja_kwadr.xls
Public delta As Variant
Public pdelta As Variant
Public a As Variant
Public b As Variant
Public c As Variant
Sub Makro1()
' Makro zarejestrowane 2004-04-26, autor nn
' Klawisz skrótu: Ctrl+q
Range("c7").Select
a = ActiveCell.Value
Range("d7").Select
b = ActiveCell.Value
Range("e7").Select
c = ActiveCell.Value
Range("k9").Select
delta = b * b - 4 * a * c
Range("c17").Select
ActiveCell.Value = delta
Range("c18").Select
If (delta > 0 Or delta = 0) And a <> 0 Then
ActiveCell.Formula = "=SQRT(c17)"
pdelta = ActiveCell.Value
'pdelta = sqrt(delta)
x1 = (-b + pdelta) / (2 * a)
x2 = (-b - pdelta) / (2 * a)
Range("c21").Select
ActiveCell.Value = x1
Range("d21").Select
ActiveCell.Value = x2
Else
If a = 0 And b <> 0 Then
x1 = -c / b
x2 = ""
Range("c21").Select
ActiveCell.Value = x1
Range("d21").Select
ActiveCell.Value = x2
Else
Range("c21").Select
ActiveCell.Value = ""
Range("d21").Select
ActiveCell.Value = ""
End If
End If
End Sub