Results 1 to 7 of 7

Populate Userform with values from table

Threaded View

  1. #1
    Forum Contributor
    Join Date
    11-08-2017
    Location
    Murfreesboro, TN
    MS-Off Ver
    MS 365
    Posts
    168

    Populate Userform with values from table

    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
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Populate UserForm List with values from an Array
    By plans in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-22-2019, 10:15 AM
  2. Populate new row in table from a form (not userform) on another worksheet
    By joeystraw in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 12-01-2018, 10:59 AM
  3. [SOLVED] populate userform with data from pivot table
    By Mathijs3 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-09-2016, 10:30 AM
  4. Populate userform from row values based on combobox
    By robertogavilan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-20-2014, 06:32 PM
  5. VLookup Excel table to populate combobox in userform
    By trecie13 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-14-2013, 02:17 PM
  6. Replies: 1
    Last Post: 11-12-2011, 05:38 PM
  7. Populate Excel table with userform data
    By waspandbee in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-21-2010, 09:34 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1