Advertisement
YasserKhalil2019

T3881_Next Record On UserForm

Sep 9th, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. https://excel-egy.com/forum/t3881
  2. ---------------------------------
  3.  
  4. Private Sub cmdNext_Click()
  5. Dim x, ws As Worksheet, rng As Range, lr As Long
  6.  
  7. Application.ScreenUpdating = False
  8. Set ws = ThisWorkbook.Worksheets("Sheet1")
  9. lr = ws.Cells(Rows.Count, 2).End(xlUp).Row
  10. Set rng = ws.Range("B1:B" & lr)
  11.  
  12. x = Application.Match(TextBox1.Value, rng, 0)
  13.  
  14. If Not IsError(x) Then
  15. Do
  16. x = x + 1
  17. If x = lr + 1 Then MsgBox "Last Record", vbExclamation: Exit Sub
  18. Loop Until ws.Cells(x, 2) <> ""
  19.  
  20. TextBox1.Value = ws.Cells(x, 2)
  21. TextBox2.Value = ws.Cells(x, 3)
  22. If ws.Cells(x, 4) = "ذكر" Then OptionButton1.Value = True Else OptionButton2.Value = True
  23. End If
  24. Application.ScreenUpdating = True
  25. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement