+ Reply to Thread
Results 1 to 4 of 4

Trying to fill textbox depending on the combobox value

  1. #1
    Registered User
    Join Date
    03-12-2015
    Location
    Netherlands
    MS-Off Ver
    2013
    Posts
    36

    Trying to fill textbox depending on the combobox value

    Hey Guys and Gals,

    I've been searching like mad man for a few hours on an issue that probably has an easy fix, I just can't find it. So i was hoping any of you could help?

    I have a sheet named "New Items" inside my workbook, on this sheet data is copied that was filled in trough a userform. Now i have set up another userform for the next user to use to add information onto that.

    In UserForm2 i have set up a ComboBox to select the wanted item, displayed in the sheet on column H, and now i want to program a textbox so that it finds and displays the values on Column Q on the same row as the selected item on Column H.

    With my limited knowledge of VBA i haven't been able to find how to do this, so if anyone can give me push in the right direction that would be amazing

    Kind Regards,

    Rekragisao

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

    Re: Trying to fill textbox depending on the combobox value

    An easy way to do it is to use the ListIndex number of the selected item in the Combobox. The ListIndex numbers in the combobox start at zero and are just a index of each item in the list. The ListIndex Number of the selected item would correspond to the relative row number of the selected item. So if the combobox is populated with values from say H2:H20, then the first selected item in the combobox would have a ListIndex number of 0. If you add 2 to that number, that would be the row number of the first item.

    The code below would populate the textbox with the value from column Q of the selected combobox item asuming the combox is populated with values starting from H2.


    Please Login or Register  to view this content.

    If that doesn't make sense, tell me how you populate your combobox and I'll adjust the code.
    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
    Registered User
    Join Date
    03-12-2015
    Location
    Netherlands
    MS-Off Ver
    2013
    Posts
    36

    Re: Trying to fill textbox depending on the combobox value

    Hey Alpha,

    Thanks for the help after altering the code slightly this works fine for me now.

    i Assigned the sheet it should get range Q from and removed the
    .Text
    property since this caused the text to be in between 2 spaces, which didn't allow me to use the value as guide towards the sheet the data has to be copied in.

    Please Login or Register  to view this content.
    Thanks again for the help

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

    Re: Trying to fill textbox depending on the combobox value

    You're welcome.

+ 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] Transfer data from textbox to sheet depending on combobox
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-10-2015, 07:25 PM
  2. [SOLVED] VBA to add data to textbox from a sheet depending on combobox value
    By mezza89 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-16-2014, 01:27 PM
  3. [SOLVED] Textbox fill based on combobox selection
    By WimpieOosthuizen in forum Excel General
    Replies: 7
    Last Post: 05-23-2014, 04:55 AM
  4. [SOLVED] autocomplete textbox depending on choice of a combobox
    By tomanton in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-04-2014, 12:47 PM
  5. [SOLVED] Fill a cell via textbox on userform depending on combobox selection
    By Rhamilton2512 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-15-2012, 10:29 AM
  6. [SOLVED] Use combobox to fill textbox within userform
    By Orestees in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 09-26-2012, 03:39 PM
  7. Combobox to fill textbox with one of 3 choices
    By nighttrainrex in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-20-2012, 02:24 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