+ Reply to Thread
Results 1 to 5 of 5

Place all items in a listbox into individual textboxes

  1. #1
    Registered User
    Join Date
    07-24-2015
    Location
    Toledo, OH
    MS-Off Ver
    Microsoft Office 2010
    Posts
    85

    Place all items in a listbox into individual textboxes

    Hello, everyone! Hoping you all can help me on this...

    I am working on a database for my company, and the users need to be able to enter new categories and subcategories for things. Right now I have a userform set up where they can type a new category name into a textbox, press a button and add the item to a listbox called "Sub1List". The problem is that now I want to take the category names they have entered in the listbox and place each of them into an individual textbox on the next page of the userform. The items will serve as headers at this point, and the user will have the opportunity to enter subcategory items beneath that category name.

    I figured I could name each of these future textbox homes "Sub1Title(i)", find the ListCount number for each list item, match the ListCount number to the textbox number, and populate the value after that. I've done matching numbers like this for numerous other projects and it works really well for me. The issue is that I can't even figure out how to return the list item values without selecting them, and I REALLY don't want to select every single item in the list in order to get the value in the right spot.

    Since I really have no idea how to do this, I have no example code. Any suggestions?

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Place all items in a listbox into individual textboxes

    You may want to consider using the Treeview object.

    A Treeview Project
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Valued Forum Contributor ranman256's Avatar
    Join Date
    07-29-2012
    Location
    Kentucky
    MS-Off Ver
    Excel 2003
    Posts
    1,177

    Re: Place all items in a listbox into individual textboxes

    no, thats not how you do it.
    2 boxes. 1 box per CAT, 1 for SUB-cat.
    and a LIST for the sub-cats.

    enter txtCat
    enter txtSub
    press Enter
    txtSub is added to the list, lstSubs
    txtSub = "" to clear the box.

    continue entering sub-cats until done.
    click POST CAT & SUB-CATS.
    this will post all records in the list to your sheet.

    clear all boxes, repeat.

  4. #4
    Registered User
    Join Date
    07-24-2015
    Location
    Toledo, OH
    MS-Off Ver
    Microsoft Office 2010
    Posts
    85

    Re: Place all items in a listbox into individual textboxes

    I had no idea the TreeView object existed. That is brilliant! Thank you!

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Place all items in a listbox into individual textboxes

    You're welcome. Thanks for the feedback.

+ 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. [SOLVED] Loop find all matches of listbox items, display results in another listbox
    By banaanas in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-29-2015, 02:56 AM
  2. Replies: 0
    Last Post: 02-04-2015, 03:46 PM
  3. [SOLVED] Auto select items in a Listbox with items from another Listbox
    By perducci in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 05-22-2013, 04:45 PM
  4. Editing listbox items in Dblclick event freezes Excel unless mouse moves over listbox
    By muneebmansoor in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-28-2013, 02:21 PM
  5. [SOLVED] VBA: transfer values of textboxes & items from listbox to worksheet
    By hydz1213 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-19-2013, 05:46 AM
  6. Transfer random listbox items to new listbox and then loop through selected items
    By narrowgate88 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-31-2013, 05:58 PM
  7. One ListBox & 3 TextBoxes
    By Rufus in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-03-2010, 02:21 AM

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