Results 1 to 7 of 7

Populate Userform with values from table

Threaded View

  1. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Populate Userform with values from table

    Hi

    I have done the following for you:

    Created a Global variable "Entry"

    Added an additional Column in your Named Range ContactSearchResults this Column Store the Row Number of the Entries.

    Added an additional Column to your listbox on your search screen. Column Width is set to 0 so it is hidden

    Selecting an Entry in the List box sets the value of Entry to the Row Number of the Entry. Entry = Listbox.value

    I have added the code to your Edit Userform to load the data from the selected Entry.

    I have also added the code to save your edited Userform.

    This code is messy but is in line with your existing code:

    My normal Code to load the Userform requires each Control be numbered to match the column where its data is.
    Textbox10's data is in column 10, Combobox11's data is in column 11 etc.

    
    On Error Resume Next
    'CF is the flag to stop macros running when a Control is modified.  Example Below
    CF = True
    
    For Count =1 To 70
          Me.Controls("CheckBox" & Count).Value = LoadArray(Count)
          Me.Controls("ComboBox" & Count).Value = LoadArray(Count)
          Me.Controls("ListBox" & Count).Value = LoadArray(Count)
          Me.Controls("Label" & Count).Caption = LoadArray(Count)
          Me.Controls("TextBox" & Count).Value = LoadArray(Count)
          Me.Controls("SpinButton" & Count).Value = LoadArray(Count)
    Next
    
    CF = False
    On Error GoTo 0
    
    
    
    Private Sub ComboBox2_Change()
    If CF = True Then Exit Sub
    TextBox2.Value = ComboBox2.Value
    End Sub
    
    Private Sub UserForm_Activate()
    If Entry < 9 Then Exit Sub
     TextBox1.Value = Cells(Entry, 3).Value
     TextBox2.Value = Cells(Entry, 4).Value
     TextBox3.Value = Cells(Entry, 6).Value
     ComboBox1.Value = Cells(Entry, 7).Value
     ComboBox2.Value = Cells(Entry, 8).Value
     ComboBox3.Value = Cells(Entry, 9).Value
     TextBox4.Value = Cells(Entry, 10).Value
     ComboBox4.Value = Cells(Entry, 11).Value
     ComboBox5.Value = Cells(Entry, 12).Value
     ComboBox6.Value = Cells(Entry, 13).Value
     TextBox5.Value = Cells(Entry, 14).Value
     TextBox7.Value = Cells(Entry, 15).Value
     TextBox9.Value = Cells(Entry, 16).Value
     TextBox11.Value = Cells(Entry, 17).Value
     TextBox13.Value = Cells(Entry, 18).Value
     TextBox15.Value = Cells(Entry, 19).Value
     TextBox6.Value = Cells(Entry, 20).Value
     TextBox8.Value = Cells(Entry, 21).Value
     TextBox10.Value = Cells(Entry, 22).Value
     TextBox12.Value = Cells(Entry, 23).Value
     TextBox14.Value = Cells(Entry, 24).Value
     TextBox16.Value = Cells(Entry, 25).Value
     TextBox17.Value = Cells(Entry, 26).Value
     ComboBox7.Value = Cells(Entry, 27).Value
     TextBox18.Value = Cells(Entry, 28).Value
     ComboBox8.Value = Cells(Entry, 29).Value
     TextBox19.Value = Cells(Entry, 30).Value
     ComboBox9.Value = Cells(Entry, 31).Value
     TextBox20.Value = Cells(Entry, 32).Value
     ComboBox10.Value = Cells(Entry, 33).Value
     TextBox21.Value = Cells(Entry, 34).Value
     TextBox22.Value = Cells(Entry, 35).Value
     TextBox23.Value = Cells(Entry, 36).Value
     TextBox24.Value = Cells(Entry, 37).Value
     TextBox25.Value = Cells(Entry, 38).Value
     TextBox27.Value = Cells(Entry, 39).Value
     TextBox26.Value = Cells(Entry, 40).Value
     TextBox28.Value = Cells(Entry, 41).Value
     TextBox38.Value = Cells(Entry, 42).Value
     TextBox29.Value = Cells(Entry, 43).Value
     TextBox39.Value = Cells(Entry, 44).Value
     TextBox30.Value = Cells(Entry, 45).Value
     TextBox40.Value = Cells(Entry, 46).Value
     TextBox31.Value = Cells(Entry, 47).Value
     TextBox41.Value = Cells(Entry, 48).Value
     TextBox32.Value = Cells(Entry, 49).Value
     TextBox42.Value = Cells(Entry, 50).Value
     TextBox33.Value = Cells(Entry, 51).Value
     TextBox43.Value = Cells(Entry, 52).Value
     TextBox34.Value = Cells(Entry, 53).Value
     TextBox44.Value = Cells(Entry, 54).Value
     TextBox35.Value = Cells(Entry, 55).Value
     TextBox45.Value = Cells(Entry, 56).Value
     TextBox36.Value = Cells(Entry, 57).Value
     TextBox46.Value = Cells(Entry, 58).Value
     TextBox37.Value = Cells(Entry, 59).Value
     TextBox47.Value = Cells(Entry, 60).Value
     ComboBox11.Value = Cells(Entry, 61).Value
     ComboBox14.Value = Cells(Entry, 62).Value
     ComboBox17.Value = Cells(Entry, 63).Value
     ComboBox13.Value = Cells(Entry, 64).Value
     ComboBox15.Value = Cells(Entry, 65).Value
     ComboBox18.Value = Cells(Entry, 66).Value
     ComboBox12.Value = Cells(Entry, 67).Value
     ComboBox16.Value = Cells(Entry, 68).Value
     ComboBox19.Value = Cells(Entry, 69).Value
    Attached Files Attached Files
    Last edited by mehmetcik; 03-11-2020 at 08:19 AM. Reason: Save Edited Userform corrected.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

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