+ Reply to Thread
Results 1 to 14 of 14

Populate table based on data in another

  1. #1
    Registered User
    Join Date
    10-20-2014
    Location
    Dublin
    MS-Off Ver
    2010
    Posts
    8

    Populate table based on data in another

    Hi there,

    I was hoping somebody might be able to help me with an issue I have.

    My spreadsheet has two tables, one of which includes an entire list of transactions. The second only contains some of the transactions from the main table i.e. it does not have any transactions that do not appear in the 'main' table.

    Up until now, the second table has been populated by copying and pasting certain entries from the main table to it but I am trying to automate this process.

    Both tables start with the same column headers. They are as follows:

    Date Invoice Number Customer Country Description Net Value Per Invoice Currency Exchange Rate Net USD Value Code


    The first table starts in Cell A13 and the second starts in A20. The second table is actually the main table. I am trying to achieve the following:

    - The column entitled 'Code' has a drop down list to select a code for the transaction.
    - The list of codes is stored in a separate sheet called Codes
    - There are 22 codes in the list. If any of 13 of the 22 are selected, I want the entire row to be populated in the table which started at cell A1.
    - The codes are in F2:F23 of the sheet entitled Codes. It is the last 13 of these in a row which I have referred to above.
    - Ideally I would like this to automatically update without even running a macro. Perhaps I could build in a refresh.all macro that runs anytime a cell is changed to trigger this.
    - I have no way of knowing how many entries will be in either table so I need the smaller table to just add a row each time the criteria is met.
    - So effectively, I want a live duplicated table which is filtered...


    Any ideas?

    Thanks in advance!

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,830

    Re: Populate table based on data in another

    It sounds like you need a Worksheet_Change event which would trigger the action automatically after selecting a code. It would be much easier to help if we could see your actual file. Could you post a copy?
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Registered User
    Join Date
    10-20-2014
    Location
    Dublin
    MS-Off Ver
    2010
    Posts
    8

    Re: Populate table based on data in another

    Thanks for the quick reply. I have attached a very rough template which will be updated once I have found a workaround for what I am trying to achieve.

    Any help would be greatly appreciated!
    Attached Files Attached Files

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,830

    Re: Populate table based on data in another

    Just a little clarification: Do you want the row from the table starting in A13 or from the table starting in A20 to be populated starting at A1? You want this to happens when a code from F11:F23 on the Codes sheet is selected from the drop down list. Is this correct?

  5. #5
    Registered User
    Join Date
    10-20-2014
    Location
    Dublin
    MS-Off Ver
    2010
    Posts
    8

    Re: Populate table based on data in another

    Quote Originally Posted by Mumps1 View Post
    Just a little clarification: Do you want the row from the table starting in A13 or from the table starting in A20 to be populated starting at A1? You want this to happens when a code from F11:F23 on the Codes sheet is selected from the drop down list. Is this correct?
    I would like the table which starts in A13 to be populated based on the data in the table which starts in A20. Correct, I would like it to populate only when one of the codes in F11:F23 of the Codes sheet is chosen. To complicate matters, I do not know how many rows will be entered at the outset, so I would need the table starting at A13 to add a row, when necessary. Hope that makes sense! Thanks

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,830

    Re: Populate table based on data in another

    Copy and paste this macro into the worksheet code module. Do the following: right click the tab for your "Workings" sheet and click 'View Code'. Paste the macro into the empty code window that opens up. Close the code window to return to your sheet. Make your code selection. Keep in mind that you should enter the data in all the other columns before selecting your code.
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    10-20-2014
    Location
    Dublin
    MS-Off Ver
    2010
    Posts
    8

    Re: Populate table based on data in another

    Thank you very much for that, it's pretty close to perfect!

    Just a few queries, if you don't mind:

    1. Is it possible to trigger the above like a normal macro i.e. call the macro to run once I have finalised the data in the lower table? I ask this because it is possible that the entries in the lower table will change. And if they do, the original copied row will remain and would need to be deleted manually.

    2. Is it possible that the inserted row will not include the values in columns O or P? So it would only copy the data in A to N inclusive.

    Thanks again.

  8. #8
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,830

    Re: Populate table based on data in another

    There may be a better way to handle that situation and have the original copied row deleted automatically. This would be possible if each row in the lower table contains a unique identifying value, for example a unique Invoice Number in column B. Will each entry in the lower table have a different Invoice Number with no duplicates in that table?

  9. #9
    Registered User
    Join Date
    10-20-2014
    Location
    Dublin
    MS-Off Ver
    2010
    Posts
    8
    Quote Originally Posted by Mumps1 View Post
    There may be a better way to handle that situation and have the original copied row deleted automatically. This would be possible if each row in the lower table contains a unique identifying value, for example a unique Invoice Number in column B. Will each entry in the lower table have a different Invoice Number with no duplicates in that table?
    No, unfortunately it is possible that the same invoice number could appear more than once. I could add a unique number for each row but keep it hidden if that helps?

  10. #10
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,830

    Re: Populate table based on data in another

    That would probably make it much neater. The unique number could be in any form you wish such as 001, 002, 003, etc.

  11. #11
    Registered User
    Join Date
    10-20-2014
    Location
    Dublin
    MS-Off Ver
    2010
    Posts
    8

    Re: Populate table based on data in another

    Updated template attached. I have added an extra column to the far left which can be hidden but I have left it visible so you can see where I put it. It could also be in column A and would work too.
    Attached Files Attached Files

  12. #12
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,830

    Re: Populate table based on data in another

    Click this link to download your file: https://app.box.com/s/0173p1qn0ll8dsayvij30hjdm37xr5ii Select your code in column J. Then make a change in some of the data and re-select the code in column J. The old data in the top table should be updated. Everything seemed to work properly for me but I think you should give it a thorough test. Please note that there is a value in cell BB1. This is a helper cell that keeps track of the first row of the lower table as rows are added and deleted in the upper table. Please make sure that you do not manually modify the value in BB1.

  13. #13
    Registered User
    Join Date
    10-20-2014
    Location
    Dublin
    MS-Off Ver
    2010
    Posts
    8

    Re: Populate table based on data in another

    Thanks for that - it works until a new row is added in lower table then it seems to stop working. Any ideas?

  14. #14
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,830

    Re: Populate table based on data in another

    Click this link to download the file. https://app.box.com/s/0173p1qn0ll8dsayvij30hjdm37xr5ii Remember to insert a unique value in column Q each time you start a new row. Also, I've eliminated the need for a helper cell in cell BB1.

+ 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] Populate data on table based on multiple criteria and value selected from drop-down
    By hcyeap in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-26-2015, 07:45 AM
  2. [SOLVED] Trying to auto-populate based on if one column matches data from another table
    By joshley2010 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-21-2014, 11:15 AM
  3. Populate data in a table based on dropdown criteria
    By Ragsbr in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-08-2014, 03:23 AM
  4. [SOLVED] Automatically populate a table with slected data based on criteria
    By smithrog in forum Excel General
    Replies: 7
    Last Post: 07-01-2013, 03:52 AM
  5. Macro to select data based in a search term and populate a table
    By Gabriel Valck in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-04-2012, 05:57 PM
  6. [SOLVED] Populate Table with data from other sheets based on drop down selection
    By nhen.enry in forum Excel - New Users/Basics
    Replies: 13
    Last Post: 09-06-2012, 10:54 PM
  7. Populate table with data based on another sheet
    By rkayasth in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-20-2009, 11:41 PM

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