+ Reply to Thread
Results 1 to 14 of 14

Populate table based on data in another

Hybrid View

  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,868

    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,868

    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,868

    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.
    Private Sub Worksheet_Change(ByVal Target As Range)
        If Intersect(Target, Range("J:J")) Is Nothing Then Exit Sub
        Application.ScreenUpdating = False
        Application.EnableEvents = False
        Dim codesArray As Variant
        Dim code As Range
        For Each code In Sheets("Codes").Range("F11:F23")
            If Target = code Then
                Rows(14).Insert
                Target.EntireRow.Copy Rows(14)
                Exit For
            End If
        Next code
        Application.EnableEvents = True
        Application.ScreenUpdating = True
    End Sub

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

    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