+ Reply to Thread
Results 1 to 15 of 15

VBA Code Help with ComboBox in Userform

  1. #1
    Registered User
    Join Date
    06-16-2016
    Location
    Michigan
    MS-Off Ver
    office365
    Posts
    26

    VBA Code Help with ComboBox in Userform

    I'm looking to use a ComboBox inside a user form to input numbers in and then have them translate into a sheet. I can get it to link to one cell, but when I change the numbers it just goes right over top the previous number. How do I get the combobox to work as intended where I can get it to let me start typing a number and if I have input that number already it shows me the rest of the number then I can click on that?

    I am attempting to use a user form to help make it easier on someone that has less knowledge of excel to input numbers so all they have to do is click some boxes and it will populate the sheet for them. So I guess maybe using just a text box would be easier because I do want the numbers to be inputted into the sheet but there will be doubles, but different dates. I hope this gives some insight into what I'm trying to do. If there are any questions as to help you help me please ask.

    Thank you in advance,
    Eric

  2. #2
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: VBA Code Help with ComboBox in Userform

    Can you attach what you have with the userform and any code you have? Also provide what you are getting and what the outcome is that you want.
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  3. #3
    Registered User
    Join Date
    06-16-2016
    Location
    Michigan
    MS-Off Ver
    office365
    Posts
    26

    Re: VBA Code Help with ComboBox in Userform

    THank you for your response gmr4evr1. I'm new to the whole code thing so I don't have any code written. I have been messing with buttons to open other files and what not and it has really peaked my intrest in this whole new VBA side of excel to me. So I'm probably biting off more than I can chew, but I know if I can just get this figured out I can apply it to anything I need. What I have so far is the design, but I'm not sure how to get the information from the user form after it opens and I put all the information in, into the sheet.... I've attached my file. It is very messy and I am sorry but maybe it will shine a little light on what I'm looking for.



    Visual Basic Testing Book.xlsm
    Attached Images Attached Images

  4. #4
    Registered User
    Join Date
    06-16-2016
    Location
    Michigan
    MS-Off Ver
    office365
    Posts
    26

    Re: VBA Code Help with ComboBox in Userform

    I did not mean for that picture to upload as well I am sorry

  5. #5
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: VBA Code Help with ComboBox in Userform

    I'm pretty sure I'll be able to help you out, but it will have to wait until tomorrow as I am about to leave for the day.

  6. #6
    Registered User
    Join Date
    06-16-2016
    Location
    Michigan
    MS-Off Ver
    office365
    Posts
    26

    Re: VBA Code Help with ComboBox in Userform

    I have had some time to work on this a little bit more. I've attached a newer copy of what ive been doing, so it may be a little more clear on what I need. I'm only looking for some help on getting just one of the comboboxes to work, and I think I should be able to translate everything else to get it to work. I really appreciate your help.
    Attached Files Attached Files

  7. #7
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: VBA Code Help with ComboBox in Userform

    Just wanted to let you know I haven't forgotten about you. The day got away from me. After looking at your last attachment, I am thinking that you want the combobox(s) to have a list of part numbers etc. in them. If this is the case there are 4 ways (that I know of) to go about doing this. My plan is to show you 3 of them using the workbook you provided. I will give an explanation of each along with pros and cons of each. The 4th one is one that I would not recommend when multiple users are going to use it. I'll also explain why this one would be a bad idea. Hopefully you didn't need this to be done yesterday.

  8. #8
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: VBA Code Help with ComboBox in Userform

    I see Tom is already to the rescue so I will only give you a sneak preview of what's possible.
    I've been playing around with your Delivered Items userform so try it out.
    Attached Files Attached Files
    Last edited by bakerman2; 12-02-2016 at 07:36 AM.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  9. #9
    Registered User
    Join Date
    06-16-2016
    Location
    Michigan
    MS-Off Ver
    office365
    Posts
    26

    Re: VBA Code Help with ComboBox in Userform

    I really appreciate the help, I am in no time crunch for this.. I am doing this as to prepare myself for the future so I can take my time and really try to learn this. So take your time I know you are doing this to help me and you can do what you can do when you have time as I'm sure you have other things that are more important.

  10. #10
    Registered User
    Join Date
    06-16-2016
    Location
    Michigan
    MS-Off Ver
    office365
    Posts
    26

    Re: VBA Code Help with ComboBox in Userform

    Thank you Bakerman2 for your imput as well. I was messing around with the file you have given me and when I input numbers I keep getting an error (Frow = error 2042) Just trying to understand the error. And thank you for adding the qty on hand to the delivery userform that is something that slipped my mind but is crucial to being able to see stock when trying to pull the part.

    Please Login or Register  to view this content.

  11. #11
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: VBA Code Help with ComboBox in Userform

    In my example all works fine. Probably something to do with the Part Numbers you are using.
    The error itself means that a number can't be found in Stock Sheet.
    Can you give some examples of the numbers as how you put them in?

  12. #12
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: VBA Code Help with ComboBox in Userform

    Thanks for the assist bakerman2.
    EM,
    I have done it another way, it's not as fancy as bakerman2's though as mine wont automatically change the description to match the part number.
    This particular way requires a "master list" sheet, I have created one in your workbook. On the master list, you list your part number, description, type etc. in columns and then reference the cells for each one in the Row Source in the properties window for the combobox(s). If your lists never change, this is a ok method to use. If your list changes or needs to be added to, then this isn't the best method to use because you would have to remember to change the RowSource cell reference(s) each time you add or take away from the list.
    To view/change the RowSource:
    Double Click the Ordered Inventory userform
    Click the Part Number combobox
    In the left pane, go to the Properties - Part_Number window
    Scroll down the list until you see RowSource
    To the right of RowSource you will see the sheet and cell references.
    I will try to get the other 2 methods to you today if you still need them.
    EmcCausland-vba-code-help-with-combobox-in-userform-visual-basic-testing-book_v1.xlsm

  13. #13
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: VBA Code Help with ComboBox in Userform

    Here are 2 other ways to do it. One way is using an array to specify what you want in the combobox which is what I did for the Part_Number combobox. The other way is with AddItem, which is what I did with the Location (ComboBox1) combobox. I did both of them in the "Received_CommandButton1_Click code for the "Received Inventory" userform. Below is the code I used
    Please Login or Register  to view this content.
    Here is the workbook...
    EmcCausland-vba-code-help-with-combobox-in-userform-visual-basic-testing-book_v1.xlsm

  14. #14
    Registered User
    Join Date
    06-16-2016
    Location
    Michigan
    MS-Off Ver
    office365
    Posts
    26

    Re: VBA Code Help with ComboBox in Userform

    Thank you for your help. I'm sorry I've been busy and haven't been able to mess around with the project for some time. I finally did get to start to mess with it and just trying out on the delivered items button I get a few issues and can't figure them out.

    1. When I type in a part number it doesn't match up the description
    2. the drop down menu has so many parts that I can't scroll to see them all
    3. I get a debug error and when I go to the debug screen this is what I see
    error.JPG

  15. #15
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: VBA Code Help with ComboBox in Userform

    I believe what is happening here is that the line before the highlighted line (the fRow =) line, is telling excel to match the part number from the Part_Number dropdown to a part number in column A. Once it finds a match, it subtracts the value in textbox3 from the value in Column C that matches the part number. Since you are adding a part number that doesn't match, it can't do what the code is telling it to do and therefore errors out because it doesn't know what to do when the part number doesn't match.

+ 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] UserForm process with IF and Combobox Selection help (Code Re-Arranged)
    By Excelnoub in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-03-2014, 01:58 PM
  2. VBA code error for userform dependent combobox
    By Jonno1 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-29-2014, 01:35 PM
  3. [SOLVED] code for updating rows based on a userform combobox selection
    By raluk_ro22 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-27-2013, 11:09 AM
  4. [SOLVED] VBA code to search using userform with multiple combobox's
    By goffa in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-18-2013, 07:43 AM
  5. [SOLVED] Help! VBA Code to disable macros and filter data for combobox in userform
    By ChristianMba in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 09-23-2012, 06:42 PM
  6. [SOLVED] I need a simple code for a click event using a UserForm ComboBox
    By Pyro Form in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-17-2012, 07:58 AM
  7. [SOLVED] Userform ComboBox populate using code?
    By Marc Cowlin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-19-2006, 09:40 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