+ Reply to Thread
Results 1 to 6 of 6

Problem with Column on a Userform

  1. #1
    Forum Contributor
    Join Date
    11-22-2006
    Posts
    100

    Problem with Column on a Userform

    Hi,

    I have got a userform with 2 Combo Boxes inter-connected (so if yu pick fruit in the first Combo Box, the second one will show bananas, apples.... and if yu pick vegetables in the first one, the second Combo Box will show Tomatoes, peas....) and a button "add". I would like in fact to write a macro so that when someone picks tomatoes, for example, and click the button "add", the price of a tomato appears on the Sheet1.
    To do that, I would like to have two columns in my second Combo Box, the first one hidden with the prices and a second column with the names "Tomatoes, peas..." so that when someone clicks "add", the macro takes the value of the first column and put it on A1 Sheet1.

    I am a really beginner and I m sure this is easy so if you can help me!!

    Thanks

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    Userforms are not good for storing data. Once the UF is unloaded, any data is lost forever. I would put the price list on a worksheet and have the routine get the value from there. The worksheet could be hidden so it doesn't interfere with the display. If Sheet2 has a list of produce in column A and a list of prices in column B.

    Please Login or Register  to view this content.
    would return the price of what is selected in ComboBox2.

  3. #3
    Forum Contributor
    Join Date
    11-22-2006
    Posts
    100
    thank yu for your answer, I m gonna try it to see if it s easier!!

    My problem with that solution is I will have probably 100 products to enter so the list will be really long! That why I put these inter connected Combo Box to make it easier or the person. Do you have any idea how can I do for this?


    Many thanks
    Last edited by koda86; 06-04-2007 at 08:47 AM.

  4. #4
    Registered User
    Join Date
    10-25-2006
    Posts
    54
    Hi Koda

    I'd go with Mike; definitely the best place to keep the data would be a worksheet and then use additem to add them in. That way you could always keep updating the list.

    Once you have the list you want in the combo box then make the width of the second column (ie the price) to be 0. It's one of the properties of the combo box. Make sure, also in the properties, that the bound column is 2 and that the column count is 2. So basically you have the second column in the combo box...you just can't see it as it doesn't have a width.

    In your macro attached to the ADD button you can return the [selected.value] to your worksheet.

    Andy

  5. #5
    Forum Contributor
    Join Date
    11-22-2006
    Posts
    100
    Thanks a lot Andy!! I am going to do by this way! As you said both, really simpler!! I will probably struggle on some points and I will probably need your help again!

    Thanks

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    This would work if ColumnA contains a list of Fruits,Column B the relevant prices, Column C the list of Vegetable with prices in D. Two comboboxes & one textbox on the userform

    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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