+ 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
    MS-Off Ver
    365
    Posts
    6,525

    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
    MS-Off Ver
    365
    Posts
    6,525

    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
    MS-Off Ver
    365
    Posts
    6,525

    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
    MS-Off Ver
    365
    Posts
    6,525

    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
    MS-Off Ver
    365
    Posts
    6,525

    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
    MS-Off Ver
    365
    Posts
    6,525

    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)

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