+ Reply to Thread
Results 1 to 21 of 21

Automatically fill some data in a textbox when I choose an option from the combo box

  1. #1
    Registered User
    Join Date
    06-17-2019
    Location
    Hyderabad
    MS-Off Ver
    2016
    Posts
    15

    Automatically fill some data in a textbox when I choose an option from the combo box

    Hey!
    I am sorry if this has been posted here before, but I'm working on this userform(Attached).
    I need to fill in build a combo box that will have various cities. When I choose a particular city I want the "Customer Number" to automatically fill with the first 3 alphabets of the city or some other alphabets that are used to abbreviate the city's name. for eg, I choose Hyderabad from the combo box and the customer number should look like "HYD001" or "HYD1"
    Can someone just mention a piece of code that can help me get started. I am stuck here and can't find a way through.

    Thankyou for any help you put forward
    Attached Files Attached Files
    Last edited by aayush_1231; 06-17-2019 at 03:50 AM.

  2. #2
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: Automatically fill some data in a textbox when I choose an option from the combo box

    Please Login or Register  to view this content.
    is that what you are looking for?

  3. #3
    Registered User
    Join Date
    06-17-2019
    Location
    Hyderabad
    MS-Off Ver
    2016
    Posts
    15

    Re: Automatically fill some data in a textbox when I choose an option from the combo box

    Hi!
    Thankyou for your reply. I actually want to get data from the combo box into my textbox.
    Like I'll choose a city and then my chosen city will be displayed in another textbox that has customer number in it

  4. #4
    Registered User
    Join Date
    06-17-2019
    Location
    Hyderabad
    MS-Off Ver
    2016
    Posts
    15

    Re: Automatically fill some data in a textbox when I choose an option from the combo box

    Quote Originally Posted by dmcgov View Post
    Please Login or Register  to view this content.
    is that what you are looking for?
    Hi!
    Thankyou for your reply. I actually want to get data from the combo box into my textbox.
    Like I'll choose a city and then my chosen city will be displayed in another textbox that has customer number in it

  5. #5
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: Automatically fill some data in a textbox when I choose an option from the combo box

    then try this:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    06-17-2019
    Location
    Hyderabad
    MS-Off Ver
    2016
    Posts
    15

    Re: Automatically fill some data in a textbox when I choose an option from the combo box

    Quote Originally Posted by dmcgov View Post
    then try this:

    Please Login or Register  to view this content.
    Does this code go under Private Sub UserForm_Initialize()?

  7. #7
    Registered User
    Join Date
    06-17-2019
    Location
    Hyderabad
    MS-Off Ver
    2016
    Posts
    15

    Re: Automatically fill some data in a textbox when I choose an option from the combo box

    Quote Originally Posted by dmcgov View Post
    then try this:

    Please Login or Register  to view this content.
    I got to work the combobox. When I choose a city, the first 3 alphabets of the city are showing but I cannot get the number in there somehow.

    My field is :-
    Customer Number :- Hyd01
    I can get to Hyd but I am stuck on how to get 01 in there.
    It gets generated automatically when i login to the userform but when i choose the city only the city name appears. the number disappears

  8. #8
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: Automatically fill some data in a textbox when I choose an option from the combo box

    can you post the code that you have? i need to see where you are getting the count variable.

  9. #9
    Registered User
    Join Date
    06-17-2019
    Location
    Hyderabad
    MS-Off Ver
    2016
    Posts
    15

    Re: Automatically fill some data in a textbox when I choose an option from the combo box

    Quote Originally Posted by dmcgov View Post
    can you post the code that you have? i need to see where you are getting the count variable.
    I have this code that generates the number when I open the userform
    Private Sub UserForm_Activate()

    Dim CUST_NUM As Long


    CUST_NUM = Cells(Rows.Count, "B").End(xlUp).Row

    Me.CUST_NUM.Value = Cells(CUST_NUM, "B").Value + 1


    End Sub

  10. #10
    Registered User
    Join Date
    06-17-2019
    Location
    Hyderabad
    MS-Off Ver
    2016
    Posts
    15

    Re: Automatically fill some data in a textbox when I choose an option from the combo box

    Quote Originally Posted by dmcgov View Post
    can you post the code that you have? i need to see where you are getting the count variable.
    and

    CUST_NUM.Text = Cells(LastRow + 1, "B").Value + 1

    generates a new number when i click on the add button in my userform.

    I have attached the userform in the initial post.
    the login credentials are :-
    admin
    saibabu

    incase you want to download and look at the code yourself

  11. #11
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: Automatically fill some data in a textbox when I choose an option from the combo box

    try this:

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    06-17-2019
    Location
    Hyderabad
    MS-Off Ver
    2016
    Posts
    15

    Re: Automatically fill some data in a textbox when I choose an option from the combo box

    Quote Originally Posted by dmcgov View Post
    try this:

    Please Login or Register  to view this content.
    where does it go? userform_initialize?

  13. #13
    Registered User
    Join Date
    06-17-2019
    Location
    Hyderabad
    MS-Off Ver
    2016
    Posts
    15

    Re: Automatically fill some data in a textbox when I choose an option from the combo box

    Quote Originally Posted by dmcgov View Post
    try this:

    Please Login or Register  to view this content.
    I put the code under Private Sub dist_change()
    dist is the (Name) of my combobox.

    I'm getting a mismatch error. The code you provided is clashing with CUST_NUM.Text = Cells(LastRow + 1, "B").Value + 1

  14. #14
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: Automatically fill some data in a textbox when I choose an option from the combo box

    i downloaded your workbook, still can't get it to work right. will keep trying.

  15. #15
    Registered User
    Join Date
    06-17-2019
    Location
    Hyderabad
    MS-Off Ver
    2016
    Posts
    15

    Re: Automatically fill some data in a textbox when I choose an option from the combo box

    Quote Originally Posted by dmcgov View Post
    i downloaded your workbook, still can't get it to work right. will keep trying.
    Sure! Thankyou so much. :D
    I'm trying too. Will update if I get to work it right. Be free to make any changes in the code you think isn't necessary or is causing trouble. let me know if you work it out
    Cheers!

  16. #16
    Registered User
    Join Date
    06-17-2019
    Location
    Hyderabad
    MS-Off Ver
    2016
    Posts
    15

    Re: Automatically fill some data in a textbox when I choose an option from the combo box

    Quote Originally Posted by dmcgov View Post
    i downloaded your workbook, still can't get it to work right. will keep trying.
    Hey!
    Any progress??

  17. #17
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: Automatically fill some data in a textbox when I choose an option from the combo box

    no luck so far, might have to ask one of the guru's for help

  18. #18
    Valued Forum Contributor
    Join Date
    05-14-2009
    Location
    gold coast
    MS-Off Ver
    Excel 2007
    Posts
    843

    Re: Automatically fill some data in a textbox when I choose an option from the combo box

    Hi,

    you need to add to your userform coding
    Please Login or Register  to view this content.

    not sure where you are getting the origional customer number from, though this MUST be a asending number or it can throw out records. Edit just seen where you are getting the unique number "this should be fine"

    hopefully dmcgov will keep helping as i am super bussy ATM, Though will cheek in when i can


  19. #19
    Registered User
    Join Date
    06-17-2019
    Location
    Hyderabad
    MS-Off Ver
    2016
    Posts
    15

    Re: Automatically fill some data in a textbox when I choose an option from the combo box

    Quote Originally Posted by dmcgov View Post
    no luck so far, might have to ask one of the guru's for help
    Ahh!
    I have searched alot with no help. My project is due in like 5 days :3
    Anyway, I'll keep searching and let me know if you make a breakthrough
    Thankyou!

  20. #20
    Registered User
    Join Date
    06-17-2019
    Location
    Hyderabad
    MS-Off Ver
    2016
    Posts
    15

    Re: Automatically fill some data in a textbox when I choose an option from the combo box

    Quote Originally Posted by D_Rennie View Post
    Hi,

    you need to add to your userform coding
    Please Login or Register  to view this content.

    not sure where you are getting the origional customer number from, though this MUST be a asending number or it can throw out records. Edit just seen where you are getting the unique number "this should be fine"

    hopefully dmcgov will keep helping as i am super bussy ATM, Though will cheek in when i can
    Sure!
    No problem. Just update me when you find a breakthrough
    Thankyou!

  21. #21
    Registered User
    Join Date
    06-17-2019
    Location
    Hyderabad
    MS-Off Ver
    2016
    Posts
    15

    Re: Automatically fill some data in a textbox when I choose an option from the combo box

    Quote Originally Posted by dmcgov View Post
    no luck so far, might have to ask one of the guru's for help
    Hi!
    I'm thinking of dropping the previous idea.
    Instead I've decided to use a list box to search my already stored values. Can you help me out with that?
    Like if I search Hydrebad, all the fields stored in Hydrebad are displayed or I can search by name of the customer or their customer number.
    Can you help me with this problem?
    I'm also uploading an updated version of the sheet where I've included a listbox and stuff.

    Thankyou!
    Attached Files Attached Files

+ 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] Drop down option automatically choose based on answer
    By haziqten in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 05-07-2019, 11:42 PM
  2. [SOLVED] Fill a textbox with varaible text depending on Radio Button selection combo
    By aprilnparker in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 08-29-2018, 06:27 AM
  3. Fill date/time in box when select option from combo box
    By coolguydudeman in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-15-2015, 09:25 AM
  4. VBA Countif to fill textbox based on two combo boxes
    By SamuelJackson in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-30-2014, 10:14 AM
  5. fill dot or slash automatically to date in Textbox
    By elevisse in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-09-2012, 07:15 AM
  6. VBA index match to to fill textbox form combo?
    By fcb1900 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-14-2010, 03:22 PM
  7. The option to choose data in Excel?
    By danakajoel in forum Excel General
    Replies: 4
    Last Post: 05-06-2010, 06:00 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