Function DSTH(CSDL As Range, Kho As String, KH As String)
ReDim Arr(1 To CSDL.Rows.Count, 1 To 4)
Dim Cls As Range: Dim W As Integer
Dim Cot As Byte
1
Cot = Switch(Kho = "A", 4, Kho = "B", 5, Kho = "C", 6, Kho = "GPE.COM", 9)
For Each Cls In CSDL(6).Resize(CSDL.Rows.Count)
3 If Cls.Value = KH Then
If CSDL.Cells(Cls.Row, Cot) > 0 Then
5 W = W + 1: Arr(W, 1) = W
Arr(W, 2) = Cells(Cls.Row, 2).Value
7 Arr(W, 3) = Cells(Cls.Row, 3).Value
Arr(W, 4) = Arr(W, 4) + Cells(Cls.Row, Cot).Value
9 End If
End If
11 Next Cls
DSTH = Arr()
End Function
Function DSNV(CSDL As Range, Ten As String)
Dim Rws As Long, J As Long, W As Integer
Dim GPE As String
Rws = CSDL.Rows.Count: W = 1
ReDim Arr(1 To Rws, 1 To 2) As String
For J = 1 To Rws
With CSDL(1).Offset(J)
If InStr(.Value, Ten) Then
W = W + 1: Arr(W, 1) = .Value
Arr(W, 2) = .Offset(, 1).Value
End If
End With
Next J
If W > 1 Then
GPE = "Có:" & Space(2) & Ten & " ?"
Arr(1, 2) = "Trong Danh Sách"
Else
GPE = "Không Có " & Space(2) & Ten & " Trong Danh Sách."
End If
Arr(1, 1) = GPE
DSNV = Arr()
End Function