'Tim kiem va nhap vao list For KIX
Public Kix_Name As String
Public Kix_NameEng As String
Public Kix_No As String
Public Kix_MU As String
Public Kix_Qty As Integer
Public Kix_M1UVar As Variant
Public Kix_Cancel As Boolean
Private Sub UserForm_Initialize()
Dim TmpArr() As Variant
'Reset gia tri tim kiem
Sheets("10.LISTDATA").Range("N1").Value = ""
'Tim dong cuoi trong bang du lieu
Dim dongcuoi As Integer
dongcuoi = Sheets("10.LISTDATA").Cells(Rows.Count, 4).End(xlUp).Row
'Khai bao mang du lieu va gan vao listbox
ReDim Preserve PartListArr(1 To dongcuoi, 1 To 7)
For i = 1 To dongcuoi
PartListArr(i, 1) = ThisWorkbook.Sheets("10.LISTDATA").Cells(i, 1).Value
PartListArr(i, 2) = ThisWorkbook.Sheets("10.LISTDATA").Cells(i, 4).Value
PartListArr(i, 3) = ThisWorkbook.Sheets("10.LISTDATA").Cells(i, 5).Value
PartListArr(i, 4) = ThisWorkbook.Sheets("10.LISTDATA").Cells(i, 8).Value
PartListArr(i, 5) = ThisWorkbook.Sheets("10.LISTDATA").Cells(i, 10).Value
PartListArr(i, 6) = ThisWorkbook.Sheets("10.LISTDATA").Cells(i, 12).Value
PartListArr(i, 7) = ThisWorkbook.Sheets("10.LISTDATA").Cells(i, 13).Value
Next
PartListData.ColumnCount = 7
PartListData.ColumnWidths = "100,100,100,100,100,100,100"
PartListData.List() = PartListArr()
'Gan gia tri cho ComboBox Type
ComboBoxType.List = Func20110301CreatDropList("10.LISTDATA", 1)
'Gan gia tri cho ComboBox Material
ComboBoxMat.List = Func20110301CreatDropList("10.LISTDATA", 5)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''Add for KIX''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim MenuWS As Worksheet
Dim ProjectName As String
Dim Filter_Type As String
Set MenuWS = ThisWorkbook.Sheets("MENU")
ProjectName = MenuWS.Range("K1").Value
Select Case ProjectName
Case "KIX"
Filter_Type = "KIX"
End Select
ComboBoxType.Value = Filter_Type
End Sub
Private Sub PartListData_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
DescriptionValue = PartListData.List(PartListData.ListIndex, 1)
MaterialValue = PartListData.List(PartListData.ListIndex, 2)
RemarksValue = PartListData.List(PartListData.ListIndex, 3)
MUValue = PartListData.List(PartListData.ListIndex, 4)
'Add for KIX
'Define ProjectName
Dim MenuWS As Worksheet
Dim ProjectName As String
Dim Filter_Type As String
Set MenuWS = ThisWorkbook.Sheets("MENU")
ProjectName = MenuWS.Range("K1").Value
Select Case ProjectName
Case "KIX"
Case Else
Unload Me
Exit Sub
End Select
'Nhap so luong
'Tao Prompt cho InputBox
Dim StrPrompt As String: StrPrompt = "Nhap so luong:"
Dim StrTitle As String: StrTitle = "Nhap so luong"
Dim InputBoxType As Integer: InputBoxType = 1 'Chi nhap gia tri so
Dim StrDefautValue As Integer: StrDefautValue = 1
Dim StrResult As Integer
Dim ResultArr As Variant
StrResult = Application.InputBox(StrPrompt, StrTitle, StrDefautValue, , , , , InputBoxType)
'when cancel
If VarType(StrResult) = vbBoolean Or StrResult = 0 Then
Kix_Cancel = True
Unload Me
Exit Sub
Else
Kix_Qty = StrResult
End If
'Tinh khoi luong cua Unit
Kix_M1UVar = PartListData.List(PartListData.ListIndex, 4)
Select Case VarType(Kix_M1UVar)
Case vbEmpty
Kix_MU = ""
Case Else
Kix_M1UVar = CDbl(Kix_M1UVar)
Kix_M1UVar = Kix_M1UVar * Kix_Qty
If Kix_M1UVar = CInt(Kix_M1UVar) Then
Kix_MU = Kix_M1UVar & ".0"
Else
Kix_MU = Kix_M1UVar
End If
End Select
Kix_Name = PartListData.List(PartListData.ListIndex, 1)
Kix_NameEng = PartListData.List(PartListData.ListIndex, 2)
Kix_No = PartListData.List(PartListData.ListIndex, 3)
Unload Me
End Sub
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Application.EnableEvents = False
Dim a As Integer
If Not Intersect(Range("A2:A50"), Target) Is Nothing And Target.Count = 1 Then
a = Target.Row
Kix_Cancel = False
PartListSearch.Show
End If
If Kix_Cancel = True Then
Application.EnableEvents = True
Exit Sub
End If
'Xoa du lieu cu
Range("D" & a & ":" & "N" & a).Value = ""
Range("D" & a & ":" & "N" & a).Interior.ColorIndex = 6
Range("A" & a).Interior.ColorIndex = 6
'Nhap cac gia tri
Range("D" & a).Value = Kix_Name
Range("E" & a).Value = Kix_NameEng
Range("F" & a).Value = Kix_No
Range("L" & a).Value = Kix_MU
Range("M" & a).Value = Kix_Qty
Application.EnableEvents = True
End Sub