+ Reply to Thread
Results 1 to 20 of 20

Macro for copying combobox entries to another sheet

  1. #1
    Registered User
    Join Date
    08-14-2009
    Location
    Lincoln, England
    MS-Off Ver
    Excel 2007
    Posts
    57

    Macro for copying combobox entries to another sheet

    Hi,

    This is a paricular problem I'm having in the middle of lots of problems, hoping you can help.

    I had created a macro to transfer information from a sheet into a seperate sheet, for storage.

    I have sinced changed the data entry sheet to use comboboxes instead of normal text, as it was important to ensure the text is entered identically each time. Now, however, my macro transfers the numerical position on the list of data for the combobox instead of it's value.

    Can anyone advise what changes I need to make?

    Thanks,

    Dom

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Macro for copying combobox entries to another sheet

    We would need to

    a) see the code

    b) know whether you're using ActiveX of Forms controls

    On an aside, you could potentially use Data Validation rather than Combo Boxes to regulate/normalise data entry

  3. #3
    Registered User
    Join Date
    08-14-2009
    Location
    Lincoln, England
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Macro for copying combobox entries to another sheet

    Hi,

    Thanks for the reply, the code is

    Please Login or Register  to view this content.
    The comboboxes are form controls.

    I used these rather than data validation, as it seems easier to control. The list of data allowed in the combobox will be added to, and data validation seemed to be a pain to keep changing.

    Thanks,

    Dom

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Macro for copying combobox entries to another sheet

    Before going too far down the route of ComboBox - I would suggest (tentatively) have a look at using Dynamic Named Ranges re: source for Data Validation lists - see link in my sig. for a guide. Not advocating one way or the other but you find DNR's a useful approach regardless.

    We should probably also see how you're populating the ComboBox (multi bound columns ?) and understand the linked cell settings that have been applied... perhaps a watered down version of the file itself ?

    I will be off line most of today but others will help.

  5. #5
    Registered User
    Join Date
    08-14-2009
    Location
    Lincoln, England
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Macro for copying combobox entries to another sheet

    If it's ok with you, I'm attaching the full version of what I've done so far. Potentially to stop me asking lots of questions later, would you be able to have a look at what I've done so far, and tell me if you think I'm going to right way about it? I've never attempted a spreadsheet anything like as complicated as this, never done forms, macros, or really anything more complicated than SUM and VLOOKUP, so I may well be making it far more complicated than I need to.

    If you could have a look, I would greatly appreciate it.

    Thanks,

    Dom
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    08-14-2009
    Location
    Lincoln, England
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Macro for copying combobox entries to another sheet

    I'm still stuck with this if anybody is able to help.

    Thanks,

    Dom


    P.S. x-reference at http://www.mrexcel.com/forum/showthread.php?t=410037

  7. #7
    Registered User
    Join Date
    08-14-2009
    Location
    Lincoln, England
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Macro for copying combobox entries to another sheet

    I've taken your advice and gone with the Dynamic named ranges. The sheet that contains all the recipes now works and picks up the correct data, thanks for that. Just going to do some data entry, then I'll be back with more questions!!

    Thanks,

    Dom

  8. #8
    Registered User
    Join Date
    08-14-2009
    Location
    Lincoln, England
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Macro for copying combobox entries to another sheet

    Hi again,

    Now that I've solved my problem with comboboxes and started using Dynamic Named Ranges, I need to reproduce the dynamic named range elsewhere on the sheet. Is there anyway I can do this automatically?

    Thanks,

    Dom

  9. #9
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Macro for copying combobox entries to another sheet

    Can you elaborate in terms of what you meant by:

    ...reproduce the dynamic named range
    If you mean you want to use the same dimensions but for a different range you can in theory "Offset" from the original but in reality we need more info.

  10. #10
    Registered User
    Join Date
    08-14-2009
    Location
    Lincoln, England
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Macro for copying combobox entries to another sheet

    Ok, it may be easier if I attach the sheet again, with the new version. Everything is now done bar one thing.

    If you look on the shopping list sheet, you will see the list of ingredients needed for each of the 5 meals. This is not particularly neat as it lists quantity, unit of measurement then description underneath each other, not in seperate columns. If you can think of a way of neatening this up, then that would be great.

    The problem now is to create the shopping list from this data, so that it adds together the quantities from the same ingredients. Hope this makes sense.

    Thanks,

    Dom
    Attached Files Attached Files

  11. #11
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Macro for copying combobox entries to another sheet

    I wonder perhaps if we're best off working backwards... I've had a look and through the file and though I have no doubt you could get this to work it will I fear prove a complex approach long term...
    The key to any spreadsheet is (in my experience) how effectively you store your source data and for that I think it's best to think in terms of databases...
    For ex. if you take your Recipe Main sheet you should really think about each Ingredient as a separate row with an additional column to specify which "master" recipe the ingredient belongs to... ie more rows / fewer columns (1 column for qty, 1 column for Unit)
    (and possible one further validation list to store a master list of recipes (presently you use column B on Recipe Main))


    Having spent a few minutes looking at this it appears to me the workflow of the file is:

    a) As and when required...

    User decides to add a new recipe
    To do so they complete Recipe Enter sheet and run macro to transfer data to new row on Recipe Main sheet
    (dropdowns are populated via your DNRs to help normalise data)

    b) On Dinners sheet user picks from options the various recipes available

    c) On Shopping List is to be populated based on ingredients required for each recipe selected on Dinners sheet

    Is that correct ?

  12. #12
    Registered User
    Join Date
    08-14-2009
    Location
    Lincoln, England
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Macro for copying combobox entries to another sheet

    Hi,

    Your assumptions about how I intend to use the sheet are absolutely right. As regards the 'master recipe' suggestion, would this not be made more difficult by the fact that an ingredient can and is used in several recipes? For example, I love my garlic! lol

    I'm fast getting out of my depth here, hell who i am kidding, I was out of my depth before I started!!

    Thanks,

    Dom

  13. #13
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Macro for copying combobox entries to another sheet

    OK, give me some time and I will put something together which I think is likely to benefit you long-term...

  14. #14
    Registered User
    Join Date
    08-14-2009
    Location
    Lincoln, England
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Macro for copying combobox entries to another sheet

    Thanks a lot.

    Of course you are welcome to use the sheet yourself if you think you would find it useful.

    Thanks,

    Dom

  15. #15
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Macro for copying combobox entries to another sheet

    you can get totals of items using offset sum product against your grand list of items
    Attached Files Attached Files
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  16. #16
    Registered User
    Join Date
    08-14-2009
    Location
    Lincoln, England
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Macro for copying combobox entries to another sheet

    Hi Martin,

    Thanks for your advise. Correct me if I'm wrong, but this would become a pain, if I were constantly adding items to the list of ingredients wouldn't it? Or could I set up the list, so that it mirrored exactly the master list of ingredients?

    Also, would it be possible to show the units of measurement and to hide the items with a 0 value?

    Sorry to be a pain,

    Dom

  17. #17
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Macro for copying combobox entries to another sheet

    well again it doesnt have to be on that sheet it could be on the ingredients tab or just mirrored like ive done =ingredients! b2
    but still reference the existing shopping list then you could simply have a button saying generate shopping list" linked to a macro that auto filtered on non 0 values and copied it to a new nice sheet that had just that info for shopping list
    like this one (macro 1) and macro 4 to reset on "real shoping list" sheet, its part recorded part adapted alot of the" selection." could be replaced but it works fine
    Attached Files Attached Files
    Last edited by martindwilson; 08-18-2009 at 08:17 PM.

  18. #18
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Macro for copying combobox entries to another sheet

    I've taken the liberty of attaching an approach that I personally feel is likely to prove beneficial long-term - I'm not advocating this over anyone elses and as always it stems from personal preferences... as such you are obliviously under no obligation to adopt etc... my ego will remain intact should you prefer not to

    Basic premise of the file is as before only now there is a Pivot Table to display current Shopping Requirements based on the current Dinner selections... as and when these selections are altered so the PT will update automatically (updated by combination of formulae on Recipe_Detail sheet and VBA Change event on Dinners sheet)

    I revised the new Recipe form a little (column G can be hidden - it's merely a basic error check) ... I re-wrote the VBA such that the header info (C2:C6) is written to the master Recipe List whilst the Ingredients info is written to the Recipe Detail sheet.

    Basic aim of all of the above is to try to keep the file looking as clean as possible whilst storing data in a database like manner. I hope it helps.
    Last edited by DonkeyOte; 08-19-2009 at 04:10 AM. Reason: zip removed - errors present (replaced in latter post)

  19. #19
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Macro for copying combobox entries to another sheet

    DrPips, I was just looking at this again and noted an error in one of the error checks... for ref. updated version attached.
    Attached Files Attached Files

  20. #20
    Registered User
    Join Date
    08-14-2009
    Location
    Lincoln, England
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Macro for copying combobox entries to another sheet

    Wow,

    Thanks a lot to both of you. I need to have a play with both of them, but if I see any problems I'll let you know. And once again, thanks a lot!!

    Dom

+ 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