Hi. I have a sample spreadsheet with userforms that I need help with.
Userforms:
ContactSearch
ContactEdit
ContactSearch:
There is a button called "Open Contact" that currently navigates to the record in the table using the following code:
Private Sub cmdGoToContact_Click()
Dim X
On Error GoTo booboo
X = Split(ListContactSearch.Column(4), "'!")
Application.Goto Sheets(X(0)).Range(X(1)), True
Unload Me
Exit Sub
booboo: MsgBox "Oops! Please click on a contact in the list, then click Go To Contact."
End Sub
I want it to open the "ContactEdit" form and populate the fields with the items from the table. How do I change the code to make that happen?
Then, I want to re-save the changes to the same line in the table. I copied the "ContactAdd" form, so the "CmdSaveChanges_Click" code puts the changed information on the next open line instead of on the same line it came from. How do I change the code to do what I want? (I didn't input all of it here since it is so many lines. All of the lines are basically the same, so here is a snipet)
Private Sub CmdSaveChanges_Click()
Dim rng As Range
Dim LastRow As Long
Set rng = ActiveSheet.ListObjects("ContactCenter").Range
LastRow = rng.Find("*", rng.Cells(1), xlFormulas, xlPart, xlByRows, xlPrevious, False).Row
rng.Parent.Cells(LastRow + 1, 3).Value = TextBox1.Value
Dim ctl As Control
For Each ctl In Me.Controls
Select Case TypeName(ctl)
Case "TextBox"
ctl.Value = ""
Case "ComboBox", "ListBox"
ctl.ListIndex = -1
End Select
Next ctl
End Sub
Bookmarks