Guest User

Untitled

a guest
Feb 22nd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. Private Sub Submit_Click()
  2.  
  3. Dim WS As Worksheet
  4. Dim lastrow As Long
  5. Dim r As Long
  6. Dim password As String
  7.  
  8. Application.ScreenUpdating = False
  9.  
  10.  
  11.  
  12.  
  13.  
  14. If Not IsNumeric(TextBox1.Text) Then
  15.  
  16.  
  17.  
  18. On Error GoTo ErrorHandler
  19.  
  20. password = TextBox1.Text
  21.  
  22.  
  23. Set WS = ActiveWorkbook.Worksheets("Accounts")
  24. lastrow = WS.Cells(Rows.Count, "A").End(xlUp).Row
  25.  
  26. For r = 2 To lastrow
  27.  
  28.  
  29.  
  30.  
  31. If WS.Cells(r, 2) = Label5.Caption Then
  32.  
  33.  
  34. WS.Cells(r, 2).Value = TextBox1.Text
  35. WS.Cells(r, 3).Value = TextBox2.Text
  36. WS.Cells(r, 4).Value = TextBox3.Text
  37.  
  38. MsgBox "Update Successful", vbInformation
  39.  
  40.  
  41. TextBox1.Text = ""
  42.  
  43. Call Edit_Login
  44.  
  45. Application.ScreenUpdating = True
  46.  
  47. Exit Sub
  48.  
  49. End If
  50.  
  51. Next
  52.  
  53.  
  54.  
  55. MsgBox "Data not Found!!", vbCritical
  56.  
  57.  
  58.  
  59.  
  60. TextBox1.Text = ""
  61.  
  62. Unload Me
  63.  
  64.  
  65. Application.ScreenUpdating = True
  66.  
  67. Exit Sub
  68.  
  69. ErrorHandler: MsgBox "Sorry an Error occured. " & vbCrLf & Err.Description
  70.  
  71. Exit Sub
  72.  
  73. End If
  74.  
  75. MsgBox "Please Enter Correct Information", vbCritical
  76.  
  77. Application.ScreenUpdating = True
  78.  
  79.  
  80. End Sub
  81.  
  82. Private Sub Edit_Login()
  83. Dim Wkbk As Workbook
  84. Dim txt As String
  85. Dim txt2 As String
  86. Dim txt3 As String
  87. Dim lastrow As Long
  88. Dim r As Long
  89. Dim Account As String
  90.  
  91.  
  92. Application.ScreenUpdating = False
  93. Application.EnableEvents = False
  94. Application.DisplayAlerts = False
  95.  
  96.  
  97.  
  98. If Not IsNumeric(TextBox1.Text) Then
  99.  
  100.  
  101.  
  102. On Error GoTo ErrorHandler
  103.  
  104. Account = TextBox1.Text
  105.  
  106.  
  107. Set Wkbk = Workbooks.Open("C:UserskameronDesktopQuality Improvement
  108. SoftwareLog In.xlsm")
  109. lastrow = Wkbk.Cells(Rows.Count, "A").End(xlUp).Row
  110.  
  111. For r = 2 To lastrow
  112.  
  113.  
  114.  
  115.  
  116. If Wkbk.Sheets("Tables").Cells(r, 1) = Label5.Caption Then
  117.  
  118.  
  119. Wkbk.Sheets("Tables").Cells(r, 1).Value = TextBox1.Text
  120. Wkbk.Sheets("Tables").Cells(r, 2).Value = TextBox2.Text
  121. Wkbk.Sheets("Tables").Cells(r, 3).Value = TextBox3.Text
  122.  
  123. MsgBox "Update Successful", vbInformation
  124.  
  125.  
  126. TextBox1.Text = ""
  127. TextBox2.Text = ""
  128. TextBox3.Text = ""
  129.  
  130. Unload EditAccount
  131.  
  132. Application.ScreenUpdating = True
  133.  
  134. Exit Sub
  135.  
  136. End If
  137.  
  138. Next
  139.  
  140.  
  141.  
  142. MsgBox "Data not Found!!", vbCritical
  143.  
  144.  
  145.  
  146.  
  147. TextBox1.Text = ""
  148.  
  149. Unload Me
  150.  
  151.  
  152. Application.ScreenUpdating = True
  153.  
  154. Exit Sub
  155.  
  156. ErrorHandler: MsgBox "Sorry an Error occured. " & vbCrLf & Err.Description
  157.  
  158. Exit Sub
  159.  
  160. End If
  161.  
  162. MsgBox "Please Enter Correct Information", vbCritical
  163.  
  164. Application.ScreenUpdating = True
  165. Application.EnableEvents = True
  166. Application.DisplayAlerts = True
  167.  
  168. End Sub
Add Comment
Please, Sign In to add comment