Advertisement
YasserKhalil2019

T4206_Search TextBox On UserForm Get Data In Multiple Sheets

Oct 26th, 2019
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. https://excel-egy.com/forum/t4206
  2. ---------------------------------
  3.  
  4. Private Sub TextBox1_AfterUpdate()
  5. Dim x, b As Boolean, ws As Worksheet, m As Double, i As Integer
  6.  
  7. For i = 1 To 5
  8. Set ws = ThisWorkbook.Worksheets(i)
  9. x = Application.Match(Val(TextBox1.Value), ws.Columns(1), 0)
  10.  
  11. If Not IsError(x) Then
  12. If b = False Then TextBox2.Value = ws.Cells(x, 2).Value: b = True
  13.  
  14. For j = 1 To 3
  15. Me.Controls("TextBox" & 3 * i + j - 1).Value = ws.Cells(x, j + 2).Value
  16. If j = 1 Or j = 2 Then Me.Controls("TextBox" & 3 * i + j - 1).Value = Format(Me.Controls("TextBox" & 3 * i + j - 1).Value, "yyyy/mm/dd")
  17. If j = 3 Then m = m + Val(Me.Controls("TextBox" & 3 * i + j - 1).Value)
  18. Next j
  19.  
  20. TextBox18.Value = m
  21. End If
  22. Next i
  23. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement