Materi Perkuliahan

Menentukan turunan fungsi Menggunakan VBA Excel

Dipublikasikan pada : 29 Januari 2020.

Sub saya()
For i = -5 To 10
Range(“A” & 9 + i) = i
Range(“B” & 9 + i) = i * 1.0000001
Range(“C” & 9 + i) = turunan1(Range(“C2”), Range(“A” & 9 + i))
Range(“D” & 9 + i) = turunan1(Range(“C2”), Range(“B” & 9 + i))
Next i
Call coba
End Sub
Function turunan(rumus, alamat)
x1 = alamat.Value
x2 = x1 * 1.0000001
y1 = alamat.Address
y3 = rumus.Value
percobaan = rumus.Formula
a = Application.ConvertFormula(percobaan, xlA1, xlA1, xlAbsolute)
b = Application.WorksheetFunction.Substitute(a, y1, x2)
y2 = Evaluate(b)
turunan = (y2 – y3) / (x2 – x1)
End Function
Function turunan1(rumus1, alamat1)
nilai = alamat1.Value
rumus = rumus1.Formula
a = Application.ConvertFormula(rumus, xlA1, xlA1, xlAbsolute)
b = Application.WorksheetFunction.Substitute(a, “x”, nilai)
turunan1 = Evaluate(b)
End Function
Sub coba()
On Error Resume Next
For i = -5 To 10
Range(“E” & 9 + i) = (Range(“D” & 9 + i) – Range(“C” & 9 + i)) / (Range(“B” & 9 + i) – Range(“A” & 9 + i))
Range(“F” & 9 + i) = Range(“E” & 9 + i) * 1.0000001
Range(“g” & 9 + i) = (Range(“F” & 9 + i) – Range(“E” & 9 + i)) / (Range(“B” & 9 + i) – Range(“A” & 9 + i))
Next i
End Sub

id_IDIndonesian