Guest User

Untitled

a guest
Jul 23rd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. Public Property Get ws() As Worksheet
  2. Set ws = ThisWorkbook.Sheets("Sheet1")
  3. End Property
  4.  
  5. Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
  6.  
  7. Dim i As Long
  8. Dim arrList As Variant
  9.  
  10. If KeyCode = 13 Then
  11. Me.ListBox1.Clear
  12. If ws.Range("D" & ws.Rows.Count).End(xlUp).Row > 1 And Trim(Me.TextBox1.Value) <> vbNullString Then
  13. arrList = ws.Range("D6:D" & ws.Range("D" & ws.Rows.Count).End(xlUp).Row).Value2
  14. For i = LBound(arrList) To UBound(arrList)
  15. If InStr(1, arrList(i, 1), Trim(Me.TextBox1.Value), vbTextCompare) Then
  16. Me.ListBox1.AddItem arrList(i, 1)
  17. End If
  18. Next i
  19.  
  20. End If
  21. If Me.ListBox1.ListCount = 1 Then Me.ListBox1.Selected(0) = True
  22.  
  23. End If
  24. End Sub
  25.  
  26. Private Sub ListBox1_Click()
  27.  
  28. Dim t As Integer, Lastrow As Long
  29.  
  30. Dim cCont As control
  31. For Each cCont In Me.Controls
  32. If TypeName(cCont) = "Image" Then
  33. cCont.Visible = False
  34. End If
  35. Next cCont
  36.  
  37. Me.TextBox1.Value = ListBox1.Value
  38.  
  39. Lastrow = ws.Cells(Rows.Count, ws.Range("tbl[Help]").Column).End(xlUp).Row
  40. For t = 6 To Lastrow
  41. If ws.Cells(t, ws.Range("tbl[Help]").Column).Value = (Me.TextBox1) Or _
  42. ws.Cells(t, ws.Range("tbl[Help]").Column).Value = Val(Me.TextBox1) Then
  43.  
  44.  
  45. If ws.Cells(t, ws.Range("tbl[Status]").Column).Value = "-7" Then Image4.Visible = True And Image3.Visible = False And Image2.Visible = False And Image1.Visible = False
  46. If ws.Cells(t, ws.Range("tbl[Status]").Column).Value = "1" Then Image2.Visible = True And Image4.Visible = False And Image3.Visible = False And Image1.Visible = False
  47. If ws.Cells(t, ws.Range("tbl[Status]").Column).Value = "2" Then Image3.Visible = True And Image4.Visible = False And Image2.Visible = False And Image1.Visible = False
  48. If ws.Cells(t, ws.Range("tbl[Status]").Column).Value = "3" Then Image1.Visible = True And Image4.Visible = False And Image2.Visible = False And Image3.Visible = False
  49.  
  50.  
  51. Me.TextBox2 = ws.Cells(t, ws.Range("tbl[Plant]").Column).Value
  52. Me.TextBox8 = ws.Cells(t, ws.Range("tbl[Name]").Column).Value
  53. Me.TextBox9 = ws.Cells(t, ws.Range("tbl[Code]").Column).Value
  54. Me.ComboBox3 = ws.Cells(t, ws.Range("tbl[Color]").Column).Value
  55. Me.ComboBox4 = ws.Cells(t, ws.Range("tbl[Status]").Column).Value
  56. Me.ComboBox2.Value = ws.Cells(t, ws.Range("tbl[Department]").Column).Value
  57. Me.ComboBox3.Value = ws.Cells(t, ws.Range("tbl[Stage]").Column).Value
  58. Me.ComboBox18 = ws.Cells(t, ws.Range("tbl[Manager]").Column).Value
  59.  
  60. End If
  61. Next t
  62.  
  63. End Sub
  64.  
  65. Private Sub CommandButton51_Click()
  66.  
  67. Dim lrCD As Long
  68. Dim i As Long, Lastrow As Long
  69.  
  70.  
  71. With ws
  72. Lastrow = .Cells(Rows.Count, .Range("tbl[Help]").Column).End(xlUp).Row
  73. For i = 6 To Lastrow
  74. If .Cells(i, .Range("tbl[Help]").Column).Value = (Me.TextBox1) Or _
  75. .Cells(i, .Range("tbl[Help]").Column).Value = Val(Me.TextBox1) Then
  76.  
  77. .Cells(i, .Range("tbl[Department]").Column).Value = Me.ComboBox2.Value
  78. .Cells(i, .Range("tbl[Stage]").Column).Value = Me.ComboBox3.Value
  79. .Cells(i, .Range("tbl[Color]").Column).Value = ComboBox4.Text
  80. .Cells(i, .Range("tbl[Plant]").Column).Value = TextBox2.Text
  81. .Cells(i, ws.Range("tbl[Manager]").Column).Value = Me.ComboBox18.Value
  82.  
  83. End If
  84. Next i
  85. End With
  86.  
  87. MsgBox "Success", , "Results"
  88.  
  89. End Sub
Add Comment
Please, Sign In to add comment