Option Explicit
Public Sub search_coefficient() '¡ÒÃËÒÊÑÁ»ÃÐÊÔ·¸ÔìºÕâÍ´Õ¹éÓ·Ôé§
Dim search_class As String '»ÃÐàÀ·
Dim search_coefficient As String 'ÊÑÁ»ÃÐÊÔ·¸Ôìbod¹éÓ·Ôé§
Dim i As Integer
Dim c_class() As String 'customer class
Dim c_coefficient() As String 'customer coefficient
Dim no_c As Integer 'Number of customer
i = 4
no_c = 0
Do Until Worksheets("sheet2").Cells(i, 1).Value = ""
i = i + 1
no_c = no_c + 1
Loop
ReDim c_class(1 To no_c)
ReDim c_coefficient(1 To no_c)
i = 4
For i = 4 To no_c
c_class(i) = Worksheets("sheet2").Cells(i, 1).Value
c_coefficient(i) = Worksheets("sheet2").Cells(i, 8).Value
Next i
search_class = Worksheets("sheet1").Range("e2").Value
i = 4
For i = 4 To no_c
If c_class(i) = search_class Then
search_coefficient = c_coefficient(i)
End If
Next i
Worksheets("sheet1").Range("H2").Value = search_coefficient
End Sub