+ Reply to Thread
Results 1 to 55 of 55

Use ComboBox value to reference table and dynamically output corresponding column data

  1. #1
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Use ComboBox value to reference table and dynamically output corresponding column data

    I've tried a few different things but I can't seem to wrap my head around this -- Or maybe I'm just showing my just how infrequently I use excel (It's true what they say, use it or lose it -- in this case, I feel like I've lost it.)... It's disconnected in my head, but I can sorta see it -- committing anything to code, however, has proved useless thus far.

    I feel like a tool for asking, but would anyone be so kind as to provide suggestion(s) on how I might implement a combobox on sheet2 to reference column values on sheet1 and dynamically output only the corresponding adjacent column values back to sheet 2?

    I've attached an example of my data... Hopefully it makes some kind of sense.

    Template example.xlsm

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Hi numbnuts

    Are your Menu Items static?

    Menus.jpg
    Menus1.jpg
    Last edited by jaslake; 02-26-2013 at 07:41 PM.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    It looks like the combobox needs the entries to be in a column not in a row

    I have modified your template for you
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Hey, thanks for the reply, jaslake -- Yes, the row menu names will remain static... The columns will remain static for the most part, too. Only the grid data may/will change... If anything else changes, it shouldn't be much of a problem to adapt, I've just not had any success with my previous attempts -- The grid I attached previously is much smaller than the data set I'm trying to sort out, which represents about 35 columns and 500 rows between 15 servers.

  5. #5
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Hi numbnuts

    The Column Headings changing will not be an issue...easily handled. The Grid Data, I believe, can/will be handled by Named Ranges (which may well be added with Code)...don't know as yet...we'll see...

    I'll play with it...not tonight...have Grandson duty in the AM. If no answer by tomorrow I'll work on it.

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Hi numbnuts

    Another question that comes to mind...will there EVER be duplicates in Column C of Sheet1? Not a deal breaker...makes things much simpler if not.

  7. #7
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Just to clarify, I'm trying to get the data on Sheet 2 to be dynamic, comprised of data from Columns A, B & C, eliminating the grid data and condensing it so that the only thing that remains is the Server Name (column A), Menu Item Number (Column B) and Menu Item Name(column C). I'm open to alternatives with how the grid data is stored if it will make coding easier, but I have yet to think of any other way that makes sense. I suppose the Menu Item Number and Menu Item Name could be merged/concatenated to reduce the number of columns that need copied, but if Server Name and Menu Name can be done, I figured a third column could probably be added easily.

    @mehmetcik
    I had considered using the listbox approach you implemented -- it works if the menu numbers and names remain static on the second sheet, however I'm actually looking for the data being displayed under the list box to update with each selection in the combobox and only the relevant data should be returned, so if no value exists, then that row shouldn't be shown...

    Also, as far as the list entries being loaded horizontally, I had played with some VBA to load the box, using

    Please Login or Register  to view this content.
    but I wasn't able to get it to populate successfully...

    @jaslake

    will there EVER be duplicates in Column C of Sheet1?
    Good question... I hadn't actually considered it before you said anything, but yes, there is a very good possibility of that occurring... A few of the menu options are in the same numerical position across multiple servers, and some have duplicates...


    Thanks, again, for taking the time...
    Last edited by numbnuts; 02-26-2013 at 10:16 PM.

  8. #8
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Hi numbnuts

    Ahhhh...I think I've got it...Sheet2 IS the output...

  9. #9
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Hi numbnuts

    See if the Code in the attached does as you require. Let me know of issues.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    WOW! You made short work of my little brainbuster, jaslake!

    I haven't yet applied it to the full-size dataset, but it looks like your code might do the trick!!! I'll study the code and try appending it to my sheet tonight and let you know how it works out.

    Thank you for your expertise!!!

  11. #11
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Just out of curiosity, was the addition of the 'Data' sheet just a redundancy to ensure that sheet1's data remain untouched?

  12. #12
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Hi numbnuts

    This is correct
    was the addition of the 'Data' sheet just a redundancy to ensure that sheet1's data remain untouched
    As you can see, Data Sheet is modified...didn't want to modify your original Sheet1.

  13. #13
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    HAHAHAAAA... I totally missed that the first time I looked at it.

  14. #14
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Jaslake,

    Thank you, again, for your assistance with this -- I was pulled away for some other work over the last couple of weeks and wasn't able to revisit this until the last day or two...

    That said, your code did the trick for the most part and I was able to change a few elements and get it to work, however I discovered that this layout requires almost as much scrolling as the previous version... Still, it's a vast improvement over trying to maintain a visual lock on each row/column intersection.

    In the interest of improving this further, I wonder if I might ask your assistance again -- I've attached an updated version with a visual to give you an idea how the output would ideally be presented -- please let me know if you think it's possible, or if you have any suggestions on how the original table might be better conceived/executed/managed.

    Many thanks...
    Attached Files Attached Files

  15. #15
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Hi numbnuts

    Will there be ONLY 2 Servers?

    Will each Server ALWAYS contain ONLY 6 Menu Items (not necessarily populated...but will they EXIST)?

  16. #16
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Jaslake,

    No, for now, there will be at least three servers, but in the future, potentially more. Currently, the menu names are roughly the same across each server and there are, currently, a maximum number of 8, however there may be more in the future and some menus may or may not be displayed based on the job titles selected. If it's possible to make the output dynamic in that those empty menus won't be shown in the formatted output, then great... If not, then no big deal -- the important thing is the horizontal format.

    Ultimately what I'm considering is, leaving the original tables alone on their respective tabs (3 on the sheet this applies to, not including what is named sheet 2 and data on our workbook (Template example v1-2.xlsm)), consolidating them to one sheet and creating the data sheet using prep_data (Module2) to make the data sheet and then pulling from that for the formatted horizontal output, if that makes any sense...

    Thanks for taking the time! your efforts are truly appreciated...

  17. #17
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Hi numbnuts

    To what are you referring here
    leaving the original tables alone on their respective tabs (3 on the sheet this applies to
    I'm not seeing this...is this another File? The File I'm looking at (Template example v1-2.xlsm) has only two Tabs...Sheet1 and Sheet2.

    Show me what you have...Some people on this Forum can write Code for what they can visualize based on your description...not me...I need to see what you see...

  18. #18
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    I don't have one prepared, unfortunately... To simplify it, though, envision three tabs, one for each server rather than consolidated as sheet1 now looks...

    In the case of 'Template example v1-2.xlsm', I only have two servers represented on sheet 1; To further clarify, if you were to recreate it with the current file, one tab for each -- server1 on one tab and server2 on another would be how it would be laid out. Then sheet3 where the combobox resides, and the fourth to be created by the prep_data module. That bit you really don't have to worry about -- I'm just trying, at this point, to get a frame of reference for how I might code the horizontal layout...

    Thanks!

  19. #19
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Hi numbnuts

    When you have your concept fully developed post back...I'll not develop it for you...don't like moving targets
    I don't have one prepared, unfortunately... To simplify it, though, envision three tabs, one for each server rather than consolidated as sheet1 now looks

  20. #20
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    I think you misunderstood -- I wasn't asking you to rebuild it... lol

    ...don't like moving targets
    I can appreciate this sentiment -- I assure you not much is going to change with sheet 1, just the addition of the third server. If I can understand how you would adapt the current vertical output to the suggested horizontal layout on sheet2, then I might likely be able to adapt and apply your logic to the third and any additional servers I might add in the future...

    I'll try and come up with something soon -- My wife's PC crashed and I'm currently knee deep in repairing the HDD and building a hardware agnostic image for it... Since I use it as our alarm clock and I return to work tomorrow, it's imperative I focus on it at the moment, before I can jump back into this...

    Thanks again for your assistance, and patience.

  21. #21
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Hi numbnuts

    The attached has Code that's been tested and works on your sample file. It WON'T work on files that don't conform to your sample file.
    When you've sorted out your requirements it can perhaps be adapted.
    Attached Files Attached Files

  22. #22
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    I lucked out with the hard drive and was able to restore from a previous image I captured, run backups and verify everything in record time to try and get back to it to complete your request -- only to find you were done! WOW! I truly envy your abilities for engineering code, jaslake. I dream of having the spatial capacity vba requires -- To execute in the amount of time you just did, twice I might add, completely blows my mind... I see things in my head, put pen to pad (so to speak) to try and figure it out, but in the end, it's usually days before I've worked it out. Inexperience with a side of split-focus, I suppose...

    Anyhow, I checked your solution and everything appeared to work flawlessly... Unfortunately, I hit a snag while playing with options from the Sheet 1 matrix to see if it was calculating properly -- I found that if you remove all values from just one menu, it returns a "Runtime error '1004': Application-defined or Object defined error". Is there any way to avoid this?

    Anyhow, brilliant imagination, my friend... Just.Brilliant.

  23. #23
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Hi numbnuts

    The Code has been designed for your sample file...
    It WON'T work on files that don't conform to your sample file. When you've sorted out your requirements it can perhaps be adapted

  24. #24
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Hi Jaslake!

    Sorry for the delay -- I tried to adapt it myself, but I wasn't able to figure it out, entirely... I thought I was very close a couple of times, but I ended up accidentally overwriting my work or crashing excel and losing the changes.

    I modified the table data with more "logical" values for error checking purposes and fleshed it out a bit more, but not alot of code -- Mostly just to make it easier to see what's happening in the output, since I can't seem to figure it out.

    I'm currently left with several anomalies -- Some of the data is being mixed in the output table, some isn't showing up at all and offsets the remainder of the data being copied, and my addition of the third server and inability to successfully hide the blank rows effectively, is subsequently causing the EntireRow.Hidden statement to hide data, rather than blank rows. I've tried multiple times, for multiple hours to get one or all of these things resolved on my own, but end up creating more problems than I do fixing any, at this point... The only time I came close to fixing it was when I had it setup to display the Server names and menus, as well as the data dynamically, much the same way you had provided in the last module, but I managed to crash excel and lose the changes...

    Anyhow, if you have the time to provide any clues, your assistance would be welcome and very much appreciated
    Attached Files Attached Files

  25. #25
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Hi numbnuts

    Play around with this...try to break it...let me know what's not happening (except formatting).
    Attached Files Attached Files
    Last edited by jaslake; 03-17-2013 at 05:44 PM.

  26. #26
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Couldn't sleep -- my mind is racing... especially now.

    I played with it a little and your code looks fantastically complicated...

    If I manage to break it, I'll let you know, but I have very little doubt that I won't be able to build off of it. I loved the backup code example, too -- got a good laugh outta that... Very good suggestion!

    I DO love gettin schooled by gurus -- Rest assured, I've learned (and I'm sure I'll continue to learn) quite a bit from your code.

    Thank you, again, for your most excellent instruction, Jaslake...

    Mind.Blown.

  27. #27
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    So I had a couple hours this morning and finished for the most part, but began having problems when I started hiding sheets... Not sure why, but what WAS working almost flawlessly is now throwing an error... It's probably something simple but after 14 hours it's difficult to think straight.

    You mentioned you had possibly resolved the formatting problem in the other post -- if you have a moment, take a look and let me know what you think might have happened. I've rearranged everything with this iteration for what should be the final layout for this stage of the project, save a few minor adjustments here or there...

    You should get the gist... The first three sheets are my answer to the "permission" problem I mentioned in the other thread, I'll end up hiding them and linking those pages to the original data source, so they're there right now as static sheets for the build, if that makes any sense...
    Attached Files Attached Files
    Last edited by numbnuts; 03-21-2013 at 10:10 AM. Reason: added third paragraph

  28. #28
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Hi numbnuts

    The biggest issue you were having is trying to select cells in an inactive sheet, for example
    Please Login or Register  to view this content.
    and
    Please Login or Register  to view this content.
    There were some missing leading DOTS and I put them in but they appear to not have been creating a CURRENT problem.

    I put in the Code to Format Sheet4...see it it's OK. I also added a Public Constant called AddRows...it's in the Module called Globals. AddRows is presently set at 25
    Please Login or Register  to view this content.
    If you find Data in Sheet4 overwriting stuff adjust this number upward. What it's doing is accommodating the number of Menu Items in each menu...AddRows can be set as high as you need/like.
    Attached Files Attached Files

  29. #29
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Looks great! I'll look over your amendments and fixes if I have the time tonight at work...

    Thanks again, Jaslake!

  30. #30
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Hey Jaslake!

    I finally got to copying the modules over to the data set I'm using and ran into a problem -- I linked the data on sheets1, 2 and 3 to read from the original workbook and modified my linked sheets to produce the same layout in our latest template example. Each sheet has all the cells populated with

    Please Login or Register  to view this content.
    I haven't had alot of time to review the code, but I'm wondering if the cell references in the linked data on sheets1, 2 and 3 might be instead, reading formulas instead of values to the output to the "Data" sheet. I know the output in linked data is generally "0", but when telling it to not print anything if the value is greater or less than "0" -- seems like it might be copying some cell information to the "Data" sheet, even though the information on "Data" looks fine. The output on "Data 1" appears to be consistent and as far as I can tell correct, but I'm getting offset values again on the final output and the menus are being offset into the Menu Number's expected cells, and all of the menu numbers are congregating in Column "K".

    Just wondering if you might have any thoughts or ideas on why this might occur... If I get the chance, I'll throw together an example table to see if I can duplicate the problem and post for your review...

    Thanks again!
    Last edited by numbnuts; 03-24-2013 at 02:03 AM. Reason: grammatical corrections

  31. #31
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Hi numbnuts

    The best I can recommend is stepping through the Code to pin down where the misalignment is happening and why.

  32. #32
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Took me a while, but I think it was the fact that I had overlooked Find("Server*", ) when I linked the original spreadsheet contents into the workbook that was causing my problem, compounded by the fact that the original sheet's format wasn't "exactly" the same as what we'd been working with.

    I did, however, introduce a bit of latency that I'm not sure how to address with my recent changes and I was wondering if you might take a look and let me know if you have any suggestions... I'm at a significant disadvantage in that I'm not at all versed in any of the debugging tools inbuilt to VBA. I've tried using them, but working with them without much experience, I liken to wearing a blindfold in a dark room without walls and legos scattered about the floor.

    Not sure why the filesize is almost a MB -- maybe the file links?
    Attached Files Attached Files

  33. #33
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Hi numbnuts

    What does this mean
    I did, however, introduce a bit of latency
    Your File Size, I'm confident, is caused by the huge number of Formulas (Links) you've introduced into the Workbook. The slowness of the Procedures is also caused by this. You might try turning Calculation Off at the Start of the Code and back On at the end of the Code like this
    Please Login or Register  to view this content.
    Beyond this, I don't know what to tell you...

  34. #34
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    I rebuilt the workbook in a fresh workbook and it reduced the filesize by another 300K or so... Once I ran the code, filesize increased to what it is now... Really, filesize isn't a huge concern -- I realize anything I add to it is only going to increase the size and or processing time and it's probably the linked data and formulas contributing to the size when compared to your last revision.

    I found that using linked data was adding 0 values to the linked data -- I'm not sure if that had any overall impact on the misalignment I was experiencing... I finally got everything working with the below code, but then in playing with the sheet realized that the 0 values might not be doing anything to the output at all, so I tried commenting out the following code in Module 2.Prep_Data

    Please Login or Register  to view this content.
    but found when commented out would result in Module 3.Finish_Up

    Please Login or Register  to view this content.
    erroring out at .Cells with 'Subscript out of range'. It works when it's un-commented, so I'm not sure exactly what it is that's not within "range" when the code isn't used since it's just an additional With expression...

    Anyway, the latency's not a huge concern either -- more of a curiosity as to whether or not there would be a better way of addressing the calculation speed or error or both. I'm fine with everything in it's current state. In any event, I'm just soooo happy to be in a somewhat completed, if not just a "working" state with this little project.

    I've attached, what should be, the final revision (with the exception of some additional aesthetic modifications) -- at some point I may come back to it and clean it up further, but now since everything just works at this point I'm going to leave it alone. Thank you again, Jaslake, for your patience and excellent assistance!

    *EDIT*

    I just refreshed the page and noticed that you had replied... I'll take a look at your suggestion and let you know -- in the meantime, I'm marking this as solved since it's, more or less, complete and I'm happy with the overall result. Thanks!
    Attached Files Attached Files

  35. #35
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    The reason I linked the data is because the original dataset being linked resides on a sharepoint server, which, if you're not familiar, requires a check-out/check-in process for accessing documents... To reduce the potential for problematic behavior, accessing the external data in this way seemed to be the simplest solution.

  36. #36
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Morning, Jaslake... I noticed something tonight when trying to update the links to the master workbook -- the menu names on sheet 4 aren't being pulled from Data1 as I had originally thought -- They're actually being created on the fly by a bit of code in the 'Finish_Up' sub:

    Please Login or Register  to view this content.
    I've spent a couple of hours off and on again trying to determine where I might be able modify your code to achieve my desired result, but I haven't been able to figure it out... It "looks like" the 'test' sub might be copying and pasting the server name value to Sheet4, but I can't figure where to integrate the menu names into the code -- Thinking about it, that approach might not work since it's there's more menu names than there are servers, which leaves it to the Split Cell "C"/"D" data and somehow integrating an offset with those (if that's even possible), maybe into the existing Arange(?). I know I've probably worn you out with this and I apologize for reviving this admittedly completed thread, but could you shed some light on how I might fix this? Without the menu names, the output, unfortunately, isn't of much use...

    Apologies and thanks...

  37. #37
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Hi numbnuts

    What seems to be the issue? What's broken? What are you trying to fix?

  38. #38
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    It seems that Column B on Data1 isn't being used in Module 3's 'test' sub and the menu names aren't being copied to the output on Sheet4. The menu names in the current output appear to be being created or possibly overwritten by the code in my last comment... I've tried commenting out those lines of code in my worksheet and the data is looks like it's not being copied at all -- with those lines commented out, the resulting output on Sheet4 lists the server name and the data from columns C and D in Data1, without menu names.

  39. #39
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Not sure if my previous reply made any sense -- to further clarify, the menu labels that are offset 1 row below each server name on Sheet4 appear to be generated by concatenating the first line of each of column D's value in the previous set value (Module2.test.Arange) pasted to Sheet4 -- the final value being something like ColumnD.value"&/&ColumnD."value" instead of ColumnB.value.

    Below is where it looks like where the copy "should" be happening with the amended code in Module2.test you've provided...

    Please Login or Register  to view this content.
    I'm "slowly" putting it all together in my head -- I guess, at this point, I'm just not clear on how to integrate Data1.ColumnB's value into your code, that is, provided my observations are correct -- I've tried a couple of ways, and nothings worked yet.

  40. #40
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Hi numnuts

    I'm not understanding the issue. I believe you're telling me your not getting the output you want/expect. I'm working with the File and Code from your Post #34. Is this the same file you're working with?

    In this file, when I select Job Title 8 the output I get is as in the attached. Please show me what you want/expect.

    By the way, I discovered what's causing the "time waster" in running the Code...perhaps you can tell me, in Prep Data, the purpose of these lines of Code
    Please Login or Register  to view this content.
    Attached Files Attached Files

  41. #41
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    I had added that code when I was testing to determine if the cell blanks (either "" or 0 values) were being read as values and throwing off the calculation and causing my aformentioned misalignment, I just hadn't removed it yet...

    Notes in the attachment...
    Attached Files Attached Files

  42. #42
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Hi numnuts

    See attached...
    Attached Files Attached Files

  43. #43
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Data updated and comments added
    Attached Files Attached Files

  44. #44
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Hi numnuts

    Try the Code in the attached
    Attached Files Attached Files

  45. #45
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    So I took a look at the change(s) you provided -- I get the feeling I've either ticked you off or you're having a funny at my expense. lol

    If the latter is true, then, good one -- I got a good laugh from it (For a few moments, I was "almost" convinced that a comma was the only thing that was preventing the code from including the needed data from Column B) If the former is true -- I sincerely apologize, that was never my intent. If I'm wrong altogether and you misunderstood my last explanation, I've provided yet another file that might clarify things further...

    In any case, thanks for your time and your help.
    Attached Files Attached Files

  46. #46
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Hi numnuts

    I'm neither "ticked" off nor having "funny" at your expense. The Code appears to give the Output desired in your Post #43. It's not as quick as the Code I posted, but then, you didn't make the other change I suggested.

    So, is there a question here?
    If I'm wrong altogether and you misunderstood my last explanation, I've provided yet another file that might clarify things further...
    Last edited by jaslake; 04-07-2013 at 08:19 PM.

  47. #47
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Your code is reading from the first line of the relative output values on sheet 4 (Columns C and D of Sheet Data1), and not from the values in Sheet Data1.ColumnB -- Your code manages to achieve the result of matching the text value and/or formatting convention I mentioned in comment 43, but if values in the code below are modified to look for elements in the values of Sheet Data1.ColumnB, or if the values in Data1.ColumnB are modifed, because those values haven't been copied and do not exist, the code bombs out.

    Please Login or Register  to view this content.
    The above code isn't necessary if the values are copied from Sheet Data1.ColumnB somewhere in the 'test' sub. I'm trying to understand how to add that data into the values that are being copied from Sheet Data1.ColumnB to the final output on Sheet4, but it's unclear to me how to do this...
    Last edited by numbnuts; 04-08-2013 at 12:10 AM.

  48. #48
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Hi numnuts

    The Code in the attached has been modified to pull values
    from the values in Sheet Data1.ColumnB
    The following changes are identified in the Code:
    In Sub Prep_Data()
    Please Login or Register  to view this content.
    In Sub test()
    Please Login or Register  to view this content.
    In Sub Finish_Up()
    Please Login or Register  to view this content.
    The attached jpg demonstrates my output for Job Title 8.
    Attached Images Attached Images
    Attached Files Attached Files

  49. #49
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Thank you for this, Jaslake... This seems to have done the trick!

    Please Login or Register  to view this content.
    I kept looking at the line above it

    Please Login or Register  to view this content.
    but the (RowOffset + 5, ColumnOffset) didn't make sense to me. It still kinda doesn't since +5, in my mind, would imply offsetting +5 rows -- given this, your addition after that (RowOffset +4, ColumnOffset), then, seems counter-intuitive with respect to placement of the output with the pastespecial directive... I'm sure I'll figure it out, eventually...

    Thanks for your patience with me, Jaslake. I haven't had alot of time to spend towards learning and working with the debugging tools (I didn't assign myself the numbnuts handle without good reason. I hope that was apparent...) -- I've learned a little about it over the course of our correspondence and to be sure, with each iteration, I've learned something new about VBA -- One of these days (hopefully sooner, rather than later), I'll be able to dedicate some time to learning how to properly use them -- speaking of which, do you have any recommendations for third party open training resources for debugging VBA, aside from the usual suspects (MSDN, Ozgrid, etc)?

    Thanks again for your time and instruction -- I'll continue to apply what I've learned from you for many years, I'm sure.

  50. #50
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Hi numnuts

    That particular Code snippet is ALWAYS working off of Cell A1 of Sheet4
    Please Login or Register  to view this content.
    Row Offset is initially set to 0
    Please Login or Register  to view this content.
    Then it's set to
    Please Login or Register  to view this content.
    and AddRows is a Constant
    Please Login or Register  to view this content.
    Step through the Code...you'll see it...

  51. #51
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Hey Jaslake!

    I wonder if I might ask your assistance one more time -- I've not been able to come back to this until recently having been ill or otherwise busy -- I've been using it somewhat regularly but I've decided to clean up one last remaining problem.

    I discovered shortly after our last correspondence that adding any servers where that server's output may not apply to the dropbox selection results in some data being carried over from the clipboard. Having dealt with that particular problem, I'm left with a server name that takes the cell formatting in the finish_up sub and subsequently put's the text partially off screen... Ultimately, I'd prefer to clear that server name's cell if no data exists for that server, but I'm perplexed as to how to accomplish it. I've tried several different ways to either clear or delete it using either the test or finish_up subs, but end up clearing or deleting the first cel.address for all of them or not affecting any data at all.

    If you have a moment, and don't mind, could you take a look and offer your thoughts/insight?
    Attached Files Attached Files

  52. #52
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Hi numnuts

    Can you give me a for instance so I can attempt to duplicate the issue?

  53. #53
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    In it's current "saved" state, Server 2's out put on sheet four is non-existent. I added some error trapping in the 'test' sub to prevent it dropping the previous paste value

    Please Login or Register  to view this content.
    When I added the On Error Resume Next statement, it would paste the last value from Server 1 into Server 2. If you remove the first line of the above code, you'll kinda see what I mean... In stopping it pasting that value, the value 'Server 2' on sheet 4 is formatted by the 'finish_up' sub and subsequently ugly to the resulting output for the entire page and not even necessary. What I had tried didn't work in removing it:

    Please Login or Register  to view this content.
    I tried placing the above before the last 'With' statement in the 'finish_up' sub (apologies, that's the only iteration of my attempts that I've saved -- I've tried various 'If/Then' one liners in various places throughout both the 'test' and 'finish_up' subs) but it blows away the 'Server 1' field and subsequently throws off the formatting of the entire sheet. In the above, I figured since there's data in next row/next column of all the other fields I wanted to keep, it would ignore those cells cell and loop until it found one where that matched the criteria; That's what most of my attempts had been generally based on -- I didn't want to blow away your "X" placeholder, so I used the cell next to it for reference in most of my attempts, but with disastrous results most of the time...

  54. #54
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Hi numbnuts

    I've added 4 lines of Code to Finish_Up...see if it works consistently for you
    Please Login or Register  to view this content.

  55. #55
    Registered User
    Join Date
    07-02-2012
    Location
    614
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Use ComboBox value to reference table and dynamically output corresponding column data

    Jaslake,

    Based on preliminary testing, your additions appear to do what I need them to; I'll merge them into my data later tonight when I'm at work to confirm...

    Thank you, yet again, for your excellent assistance!!!

+ 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