Public Function NoiSuy100(x As Double, x1 As Double, x2 As Double, y1 As Double, y2 As Double) As Double
NoiSuy100 = ((x - x1) * (y2 - y1)) / (x2 - x1) + y1
End Function
'So lieu hang cot phai xap xep tang dan hoac giam dan
Public Function NoiSuy200(x As Double, x1 As Range, y1 As Range, n As Integer, HC As String)
Dim i As Integer
If HC = "row" Then
i = x1.Columns.Count
If x1.Cells(1, 2) > x1.Cells(1, 1) Then
For i = 1 To x1.Columns.Count - 1
If x1.Cells(1, i) >= x Then Exit For
Next
Else
For i = 1 To x1.Columns.Count - 1
If x1.Cells(1, i) <= x Then Exit For
Next
End If
NoiSuy200 = NoiSuy100(x, x1.Cells(1, i - 1), x1.Cells(1, i), y1.Cells(n, i - 1), y1.Cells(n, i))
Else
i = x1.Rows.Count
If x1.Cells(2, 1) > x1.Cells(1, 1) Then
For i = 1 To x1.Rows.Count - 1
If x1.Cells(i, 1) >= x Then Exit For
Next
Else
For i = 1 To x1.Rows.Count - 1
If x1.Cells(i, 1) <= x Then Exit For
Next
End If
NoiSuy200 = NoiSuy100(x, x1.Cells(i - 1, 1), x1.Cells(i, 1), y1.Cells(i - 1, n), y1.Cells(i, n))
End If
End Function