Option Explicit
Dim i&, iPos&, LastRow&
Dim sTxt$
Dim Dic As Object
Dim ArrTmp, Arr(1 To 5)
Private Sub ComboNCC_Enter()
SendKeys ("%{DOWN}")
End Sub
Private Sub TextBox1_AfterUpdate()
TextBox1 = Format(TextBox1, "dd/mm/yyyy")
End Sub
Private Sub UserForm_Initialize()
ArrTmp = Array("TextBox1", "ComboNCC", "TextBox3", "TextBox5", "TextBox4")
Set Dic = CreateObject("Scripting.Dictionary")
For i = LBound(ArrTmp) To UBound(ArrTmp)
Dic.Add ArrTmp(i), i + 1
Next i
LastRow = Sheet2.Range("A65000").End(xlUp).Row
ComboNCC.RowSource = "'" & Sheet2.Name & "'!A2:b" & LastRow
End Sub
Private Sub ComboNCC_afterUpdate()
TextBox3 = ComboNCC.Column(1)
End Sub
Private Sub TextBox4_Change()
TextBox4 = Format(TextBox4, "#,##0")
End Sub
Private Sub CommandButton1_Click()
LastRow = Sheet3.Range("a50000").End(xlUp).Row + 1
LayConTrol
With Sheets("Data")
.Cells(LastRow, 1).Resize(, 5) = Arr
End With
Erase Arr
End Sub
Sub LayConTrol()
i = 0
Dim Ctr As Control
For Each Ctr In NHAPLIEU.Controls
If TypeOf Ctr Is MSForms.TextBox Or TypeOf Ctr Is MSForms.ComboBox Then
i = i + 1
sTxt = Ctr.Name
iPos = Dic.Item(sTxt)
Arr(iPos) = Ctr.Value
Ctr.Value = ""
End If
Next
Arr(5) = Arr(5) * 1
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub