Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. Public Guncode As String
  2. Option Explicit
  3.  
  4. Sub Test()
  5.  
  6. Call Vlookup
  7.  
  8. End Sub
  9.  
  10. Sub Vlookup()
  11.  
  12. Dim Retrieve1 As String
  13. Dim Retrieve2 As String
  14. Dim FinalRow As Long
  15. Dim FinalColumn As Long
  16. Dim WholeRange As String
  17.  
  18. If GunTest.TextBox1 = "" Then
  19. Exit Sub
  20. If GunTest.TextBox1 <> "" Then
  21.  
  22. MsgBox Guncode
  23. End If
  24. End If
  25.  
  26. With Sheets(1)
  27.  
  28. FinalRow = Range("A65536").End(xlUp).Row
  29. FinalColumn = Range("IV1").End(xlToLeft).Column
  30. WholeRange = "A2:" & CStr(FinalColumn) & CStr(FinalRow)
  31.  
  32. Retrieve1 = Application.WorksheetFunction.Vlookup(Trim(Guncode), Range(WholeRange), 1, False) 'Locate specific tool according to QR code number
  33. Retrieve2 = Application.WorksheetFunction.Vlookup(Trim(Guncode), Range(WholeRange), 5, False) 'Locate specific gun type according to QR code number
  34.  
  35. If Guncode = "" Then
  36. MsgBox "This gun doesn't exist in database!"
  37. Else
  38. MsgBox "The tool number is:" & Retrieve1 & vbCrLf & "The gun type is:" & Retrieve2
  39. End If
  40. End With
  41.  
  42.  
  43. End Sub
  44.  
  45. Option Explicit
  46.  
  47. Private Sub Label1_Click()
  48.  
  49. End Sub
  50.  
  51. Private Sub CommandButton1_Click()
  52.  
  53. If TextBox1 = "" Then Exit Sub 'Set condition 1 of exiting the program
  54.  
  55. Guncode = GunTest.TextBox1
  56.  
  57. With Me
  58.  
  59. Call Module1.Test
  60.  
  61. End With
  62.  
  63.  
  64.  
  65. End Sub
  66.  
  67. Private Sub PartID_Click()
  68.  
  69. End Sub
  70.  
  71. Private Sub TextBox1_Change()
  72.  
  73. End Sub
  74.  
  75. Private Sub UserForm_Click()
  76.  
  77. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement