+ Reply to Thread
Results 1 to 7 of 7

UserForm and Cell Data to ListBox

  1. #1
    Registered User
    Join Date
    10-31-2023
    Location
    NYC
    MS-Off Ver
    365
    Posts
    4

    UserForm and Cell Data to ListBox

    Hello!

    I am creating a UserForm that is used to add a new entry or edit an existing entry in a worksheet. The last tackle is the ListBox. The ListBox contains a number of comment codes, pulled from a table in a different worksheet.

    I assigned a variable to aid in getting the selected data in the UserForm's ListBox (there are actually 3) to the cell in the appropriate column in the worksheet when a new entry is created.

    How do I go about retrieving the data from this cell and select all matching option codes in the ListBox?
    If I go to edit an entry in the table using the UserForm, I want these codes to highlight in the UserForm ListBox so I can make easy changes. Something like this.

    Screenshot 2023-10-31 220327.png

    Thanks!
    Last edited by jcv23; 11-01-2023 at 06:48 PM. Reason: Typo

  2. #2
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,411

    Re: UserForm and Cell Data to ListBox

    See big yellow banner - How to upload your workbook - far easier then to give you a solution - we can not manipulate pictures.
    Torachan,

    Mission statement; Promote the use of Tables, Outlaw the use of 'merged cells' and 'RowSource'.

  3. #3
    Registered User
    Join Date
    10-31-2023
    Location
    NYC
    MS-Off Ver
    365
    Posts
    4
    Quote Originally Posted by torachan View Post
    See big yellow banner - How to upload your workbook - far easier then to give you a solution - we can not manipulate pictures.
    For sure! I was hoping more for a starting point/process to get me going and figured pictures would suffice for now.

  4. #4
    Registered User
    Join Date
    10-31-2023
    Location
    NYC
    MS-Off Ver
    365
    Posts
    4
    Quote Originally Posted by jcv23 View Post
    For sure! I was hoping more for a starting point/process to get me going and figured pictures would suffice for now.
    But, yes. I’ll upload the workbook at some point today.

  5. #5
    Registered User
    Join Date
    10-31-2023
    Location
    NYC
    MS-Off Ver
    365
    Posts
    4

    Lightbulb Re: UserForm and Cell Data to ListBox

    Torachan: Thanks for the push to upload the workbook. I should've just done it from the get.

    All: Thanks in advance for the help. The 'UserForm File' workbook is uploaded. I obviously had loads of changes to make to it prior to posting. I kept the important code to help streamline reaching a solution, deleted the rest, and left a couple comments in the code.

    I very much look forward to completing this project. I'm not a developer or Excel master by trade, but this is something I took on to help manage a database which is now becoming very large. I got this far! I look forward to everyone's take on a solution.
    Last edited by jcv23; 11-04-2023 at 02:25 PM.

  6. #6
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,411

    Re: UserForm and Cell Data to ListBox

    Give the attached a trial - using separate userforms creates extra work transferring variables/data across (need to use public variables etc.) - if you still want to keep separate use a second page of the multipage you have already put on your form(this will give you the same effect as a second form but will keep all the variables in the same userform app.
    Using the combobox to select your data for Updating/Deleteing there is no need for search routines as there is a direct link between the .listindex and the table row (you will see a variable 'sc' - as the variables are declared at the head of the code immediately after Option Explicit they are then available across all Subs - if declared within a Sub they are specific to that Sub).
    To add a new record first press 'CLEAR', this ensure the form is clear and activates the 'ADD' button - enter your data when complete press 'ADD' - the other buttons should be intuitive.
    If you need further help post back in this thread.
    Attached Files Attached Files

  7. #7
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,411

    Re: UserForm and Cell Data to ListBox

    glad to have helped - thanks for the added rep point.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. resize the listbox & userform based on populated data in listbox
    By Mussa-A in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-03-2022, 09:14 AM
  2. Replies: 1
    Last Post: 04-12-2022, 04:38 PM
  3. [SOLVED] Userform Listbox selected data transferred to a Worksheet cell
    By Tony Hadj in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-25-2014, 02:51 AM
  4. Transfer Data From One Userform Listbox to Another Userform Listbox with 11 columns
    By sparkoft in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 05-18-2013, 10:54 AM
  5. userform listbox
    By tsiguy96 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-14-2013, 11:09 PM
  6. Listbox to Listbox, no duplicates & submitting same UserForm data for each Listbox entry.
    By jamieswift1977 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-18-2012, 12:18 PM
  7. Display a UserForm based on Data selected in another UserForm's ListBox
    By RPhilbin83 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-26-2011, 11:35 AM

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