Attribute VB_Name = "AISC_Function"
Option Explicit

Function AISC(Section As String, Property As String) As Variant
    
    'Dimension Variables
    Dim LimY As Long, LimX As Long
    Dim i As Long, j As Long, k As Long
    
    'Find the last column and row
    LimY = WorksheetFunction.Max(2, AISCDB.Cells(Rows.Count, "A").End(xlUp).Row)
    LimX = WorksheetFunction.Max(1, AISCDB.Cells(1, Columns.Count).End(xlToLeft).Column)
    
    'Find Row
    For i = 2 To LimY
        'If match is found, exit loop
        If Section = AISCDB.Cells(i, 3) Then Exit For
    Next i
    
    'Find Column
    For j = 1 To LimX
        'If match is found, exit loop
        If Property = AISCDB.Cells(1, j) Then Exit For
    Next j
    
    'Report Error if no match is found
    If i > LimY Or j > LimX Then
        AISC = "Err"
    Else
        'Output based on column and row index found above
        AISC = AISCDB.Cells(i, j).Value
    End If

End Function

