+ Reply to Thread
Results 1 to 8 of 8

Updating cells and text box's with ComboBox

  1. #1
    Registered User
    Join Date
    03-05-2008
    MS-Off Ver
    Office 2016 and 365
    Posts
    48

    Updating cells and text box's with ComboBox

    Hi,

    Please help,

    I have a number of text box's on a userform, there's a ComboBox with 1-10 in the list (combo_box1). When a number is selected I would like it to do the following:-

    1. Update cells in sheet1
    2. Update text box's on the same userform, but also, when changes are made in these text box's the cells in sheet1 are also updated (same cells as point 1)

    So, lets say, when number "1" is selected in comobo_box1, I enter the details in the text box's on the form, this then copies the information from the text box's to the cells in sheet1. This is then repeated for the other 9 items in combo_box1.
    However, if I go back to "1" in the combo_box1 and make changes to the text box's on the userform, this also needs to update the cells in sheet1.

    Does this make sense and is this possible ?

    I don't have any code at the moment, not sure if this is possible.


    Thanks in advance
    Last edited by styoda; 09-12-2019 at 09:08 AM.

  2. #2
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Updating cells and text box's with ComboBox

    Use the TextBox's ControlSource property. If you post what does what we can show how. e.g.
    1, Data!A1, TextBox1 - Data!A2, Textbox2, etc.

    Here is the concept with a more complicated set of linked cells, controlsource.
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-05-2008
    MS-Off Ver
    Office 2016 and 365
    Posts
    48

    Re: Updating cells and text box's with ComboBox

    Hi Kenneth,

    Thanks very much for you help, I managed to manipulate your code and get it working for the first entry in the ComboBox1, but not the others.
    However, I have come across a problem, I've named each textbox and there's also other combobox's, which has complicated things, and now nothing works, because of this. In hindsight I should have renamed each box, but this is only a small part of project and the other code in the project is just way to big to change.

    I know naming the text/combo box's will increase my code somewhat, but if you would be so kind and help with just the first entry in ComboBox1 then I should be able to do the rest.

    To make you aware:-
    If ComboBox1 = 1 then
    Email Account = A2
    Customer Delivery Site = B2
    Account Number = C2
    etc
    If ComboBox1 = 3 then
    Email Account = A4
    Customer Delivery Site = B4
    Account Number = C4
    etc

    I've attached my workbook, can you please have a look as see what you can do ?


    Thanks very much,
    Attached Files Attached Files

  4. #4
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Updating cells and text box's with ComboBox

    This sets your controlsource property based on the listindex of the combbox. This is the row number +1 to skip row 1 headings.

    Here is the main trick. Add the column letter in the Tag Property for each control that you want to set a controlsource property. This basically links the control value to the cell value. Change one and it changes the other.

    As coded, it assumes that the sheet is active when you show the userform.

    Please Login or Register  to view this content.

    Be sure to test on a backup copy.

  5. #5
    Registered User
    Join Date
    03-05-2008
    MS-Off Ver
    Office 2016 and 365
    Posts
    48

    Thumbs up Re: Updating cells and text box's with ComboBox

    Thanks very much Kenneth, it works perfectly.


  6. #6
    Registered User
    Join Date
    03-05-2008
    MS-Off Ver
    Office 2016 and 365
    Posts
    48

    Re: Updating cells and text box's with ComboBox

    Hi Kenneth,

    I should have asked this earlier, can you please let me how I can run this code from another sheet (sheet2 for example)

    Thanks

  7. #7
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Updating cells and text box's with ComboBox

    There are several ways to run it from other sheets.

    For the cell references in the userform to a sheet other than activesheet, there are two fixes for that. (1) Add the worksheet object prefix:
    Please Login or Register  to view this content.
    and (2), add the sheet name in the Tag for each control or set it at run time like this with the prefix added:
    Please Login or Register  to view this content.
    Last edited by Kenneth Hobson; 09-23-2019 at 02:47 PM.

  8. #8
    Registered User
    Join Date
    03-05-2008
    MS-Off Ver
    Office 2016 and 365
    Posts
    48

    Re: Updating cells and text box's with ComboBox

    Thanks very much once again Kenneth, works perfectly.

+ 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. my combobox is not updating
    By tyneexi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-04-2018, 10:56 AM
  2. Updating Text Box with Cell Values based on ComboBox Selection
    By Huskersippi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-31-2016, 02:19 AM
  3. [SOLVED] Combobox - insert text to cells
    By Lukael in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-28-2014, 02:09 AM
  4. Automatically updating cells with different text once the result is inputted...
    By ajames715 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-31-2012, 03:36 PM
  5. Updating Combobox after Other Combobox is run
    By Maglor in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-28-2009, 05:59 AM
  6. Combobox to determine text for a range of cells
    By Robbyn in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-26-2006, 10:25 AM
  7. [SOLVED] Compare Text/combobox values against cells in spreadsheet
    By BigPig in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-20-2006, 01:30 PM

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