Hàm nội suy 2 chiều trong Excel
Option Explicit ‘Tran Van Sy_TECCO 533 Public Function NS2C(ra As Range, ro_lo As Double, co_lo As Double) 'Cu phap: NS2C([lookup_range], lookup_value_X, lookup_value_Y) Dim iro As Integer, ico As Integer Dim i As Integer, j As Integer Dim d01 As Double, d02 As Double Dim d10 As Double, d20 As Double Dim d11 As Double, d12 As Double Dim d21 As Double, d22 As Double Dim d3 As Double, d4 As Double Dim d As Variant Dim ar() As Double 'Kiem tra loi On Error GoTo kt iro = ra.Rows.Count ico = ra.Columns.Count ReDim ar(1 To iro, To ico) As Double For i = To iro For j = To ico ar(i, j) = ra.Cells(i, j).Value Next Next If ro_lo < ar(2, 1) Or ro_lo > ar(iro, 1) Or _ co_lo < ar(1, 2) Or co_lo > ar(1, ico) Then d = "Loi" Else For i = To iro - d10 = ar(i, 1) d20 = ar(i + 1, 1) If ro_lo >= d10 And ro_lo = d10 And ro_lo ar(iro, 1) Or _ co_lo < ar(1, 2) Or co_lo > ar(1, ico) Then d = "Loi" Else For i = To iro - d10 = ar(i, 1) d20 = ar(i + 1, 1) If ro_lo >= d10 And ro_lo