+ Reply to Thread
Results 1 to 13 of 13

Fill textbox contents based on ComboBox selection

  1. #1
    Registered User
    Join Date
    07-02-2013
    Location
    orlando
    MS-Off Ver
    Excel 2003
    Posts
    10

    Fill textbox contents based on ComboBox selection

    I have trying to auto fill textboxes based on the ComboBox selection, but I keep getting a "Run time error 9, subscript out of range" Can't find the issue with the code, see below.

    Please Login or Register  to view this content.
    Last edited by am9293; 01-09-2019 at 03:46 PM.

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,075

    Re: Fill textbox contents based on ComboBox selection

    A few things
    1) It would help if you told us which line of code was failing.
    2) Your quotes are wrong they should be " not the sloping quotes you have used.
    3) Do you have a sheet called Sheet4?
    4) In you combo change event you are using ws.Cells, but have not assigned anything to it.

  3. #3
    Registered User
    Join Date
    07-02-2013
    Location
    orlando
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Fill textbox contents based on ComboBox selection

    I get a error message box, it doesn't highlight which line of code is failing.
    Fixed the quotes, still same error
    Yes, to Sheet4
    I found and modified this code from another site online, so not sure how to assign.

  4. #4
    Registered User
    Join Date
    07-02-2013
    Location
    orlando
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Fill textbox contents based on ComboBox selection

    So I ran my setup from the beginning and it shows the following error...

    error.jpg

  5. #5
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,075

    Re: Fill textbox contents based on ComboBox selection

    In the VB editor select Tools > options > General > select "Break in class module" > Ok
    The try running the code again

  6. #6
    Registered User
    Join Date
    07-02-2013
    Location
    orlando
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Fill textbox contents based on ComboBox selection

    The error now shows as

    Set ws = Sheets("Sheet4")

    error2.jpg

  7. #7
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,075

    Re: Fill textbox contents based on ComboBox selection

    In that case you don't have a sheet called sheet4.
    Are you looking at the name on the sheet tab, or the name shown in the Editor like Sheet4(Something)
    You also still have incorrect quotes

  8. #8
    Registered User
    Join Date
    07-02-2013
    Location
    orlando
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Fill textbox contents based on ComboBox selection

    Oh geez, ok that was simple fix.....duh...

    But now, when the UserForm runs, by TextBoxes don't get filled in....

  9. #9
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,075

    Re: Fill textbox contents based on ComboBox selection

    Try
    Please Login or Register  to view this content.
    where the line in blue is at the very top of the module, before any code.

    Also please edit you original post to include code tags, the #icon in the reply/edit window.

  10. #10
    Registered User
    Join Date
    07-02-2013
    Location
    orlando
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Fill textbox contents based on ComboBox selection

    Ok, added your suggested code, Userform works, but TextBoxes do not autofill when I select an option from the ComboBox

    Please Login or Register  to view this content.

  11. #11
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,075

    Re: Fill textbox contents based on ComboBox selection

    How about
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    07-02-2013
    Location
    orlando
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Fill textbox contents based on ComboBox selection

    I got it, thanks for your help

  13. #13
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,075

    Re: Fill textbox contents based on ComboBox selection

    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. TextBox Entry based on Combobox Selection
    By tigerdel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-04-2016, 01:12 PM
  2. [SOLVED] Textbox fill based on combobox selection
    By WimpieOosthuizen in forum Excel General
    Replies: 7
    Last Post: 05-23-2014, 04:55 AM
  3. Populate textbox based off ComboBox Selection
    By ladams41 in forum Excel General
    Replies: 1
    Last Post: 04-09-2014, 10:13 AM
  4. Populate TextBox based off ComboBox selection
    By ladams41 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-07-2014, 01:24 PM
  5. [SOLVED] fill combobox selection based on a selection from the first combobox
    By Monza in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-14-2013, 07:34 PM
  6. Fill a cell via textbox according to combobox selection
    By dj_danu01 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-15-2013, 08:12 AM
  7. [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

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