Hi, me again, Sorry for ask many question, I am new in vba excel.
I have a form, this form allows you to look for a person (probably I have many people named David), in case you have many registers with one name (but different last name) you can pick wich register you want to update.
once you select a person , a new form is displayed
what I want to do is, once you select the person in the first form, and click in Modify, i would like to be able to see the information of that particular person displayed in this second form, and will be able to edit it.
Now, the code that I have in the second form is
Thank you
I have a form, this form allows you to look for a person (probably I have many people named David), in case you have many registers with one name (but different last name) you can pick wich register you want to update.
once you select a person , a new form is displayed
what I want to do is, once you select the person in the first form, and click in Modify, i would like to be able to see the information of that particular person displayed in this second form, and will be able to edit it.
Now, the code that I have in the second form is
VBA Code:
Private Sub btnEdit_Click()
Dim vol_name As String
vol_name = Trim(txtbox.Text)
lastRow = Worksheets("Registers").Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastRow
If Worksheets("Registers").Cells(i, 2).Value = vol_id Or Worksheets("Registers").Cells(i, 3).Value = vol_name Then
answer = MsgBox("Are you sure you want to update the record?", vbYesNo + Question, "Update Record")
If answer = vbYes Then
Worksheets("Registers").Cells(i, 3).Value = txtvolName.Text
Worksheets("Registers").Cells(i, 4).Value = txtvolLastName.Text
Worksheets("Registers").Cells(i, 5).Value = txtvolEmail.Text
Worksheets("Registers").Cells(i, 6).Value = txtvolAddress.Text
Worksheets("Registers").Cells(i, 7).Value = txtcity.Text
Worksheets("Registers").Cells(i, 8).Value = txtcounty.Text
Worksheets("Registers").Cells(i, 9).Value = txteircode.Text
Worksheets("Registers").Cells(i, 10).Value = txtphone.Text
Worksheets("Registers").Cells(i, 11).Value = txttwitter.Text
Worksheets("Registers").Cells(i, 12).Value = schedule_list.Text
Worksheets("Registers").Cells(i, 13).Value = txtgarda.Text
Worksheets("Registers").Cells(i, 14).Value = help_list.Text
Worksheets("Registers").Cells(i, 15).Value = txtzendesk.Text
Worksheets("Registers").Cells(i, 16).Value = txtmicro_365.Text
MsgBox "The record is updated"
Exit Sub
Else
MsgBox "The record is not going to be updated"
Exit Sub
End If
End If
Next
Unload Me
End Sub
Private Sub UserForm_Initialize()
frmUpdateVolunteer.Show
For i = 1 To 3
Me.Controls("Textbox" & i).Value = ActiveCell.Offset(0, i - 1).Value
Next i
End Sub
Thank you