Populate Table with filtered data from another table.

joshuadalrymple

New Member
Joined
Sep 22, 2015
Messages
4
Hello everyone,

I have a spreadsheet at work that requires me to put the same information into two separate tables on two separate sheets. The master list containing all of the information unfiltered is on sheet name Raw and is shown below.

Each "Name" has their own sheet with an identical table that has the same information on it, just specifically the information corresponding to that name.

As of right now I must enter the information manually on the master table as well as the specific tables for each name. This is quite cumbersome.

What I would like to do is have the tables on the specific "name" worksheets auto fill from the information on the master table.

Unfortunately due to workplace, IT, and other restrictions, Power Query, Pivot Tables, and SQL will not work.

Some extra info:

  • Trans # is the only unique number as each "name" will have many entries and ID# (although unlikely) could repeat.
  • The table names on each of the specific "name" sheets will be the same as the "name".
  • The specific "name" sheets have other information on them, so they can't be removed.
  • At this time I cannot upload a copy of the spreadsheet. Later, I may be able to upload an example copy if that's needed.


Sheet Name: Raw
Table Name: Ledger
Trans #NameID #Minutes1st ChangeSubsequent ChangesSecondsOutlier
1John Smith662474650.3y 18N
2Jane Doe654464160.6n218N
3Jack Green674516781y 60N
4Jill Brown467648762y 120N
5John Smith741616872y 120N
6Jane Doe468724192y 120N
7Jack Green684687612y 120N
8Jill Brown768764171n160N
9John Smith687687121n160N



<colgroup><col><col><col><col><col><col><col><col></colgroup><tbody>
</tbody>

Thank you for whatever help you can offer!
 

Some videos you may like

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,593
Office Version
  1. 2007
Platform
  1. Windows
Try this

Change "master" for the name of your master sheet

Code:
Sub Populate_Table()
  Dim c As Range, sh As Worksheet, ky As Variant
  Set sh = Sheets("[B]master[/B]")
  With CreateObject("scripting.dictionary")
     For Each c In sh.Range("B2", sh.Range("B" & Rows.Count).End(xlUp))
        .Item(c.Value) = Empty
     Next c
     For Each ky In .Keys
        sh.Range("A1").AutoFilter 2, ky
        sh.AutoFilter.Range.Offset(1).EntireRow.Copy Sheets(ky).Range("A" & Sheets(ky).Range("A" & Rows.Count).End(xlUp).Row + 1)
     Next ky
  End With
  sh.ShowAllData
End Sub
 

joshuadalrymple

New Member
Joined
Sep 22, 2015
Messages
4
I'll admit I'm not too familiar with VBA, so maybe I'm placing the code in the wrong spot, but when I put it in the Master I get the error, "Subscript out of range".


Try this

Change "master" for the name of your master sheet

Code:
Sub Populate_Table()
  Dim c As Range, sh As Worksheet, ky As Variant
  Set sh = Sheets("[B]master[/B]")
  With CreateObject("scripting.dictionary")
     For Each c In sh.Range("B2", sh.Range("B" & Rows.Count).End(xlUp))
        .Item(c.Value) = Empty
     Next c
     For Each ky In .Keys
        sh.Range("A1").AutoFilter 2, ky
        sh.AutoFilter.Range.Offset(1).EntireRow.Copy Sheets(ky).Range("A" & Sheets(ky).Range("A" & Rows.Count).End(xlUp).Row + 1)
     Next ky
  End With
  sh.ShowAllData
End Sub
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,593
Office Version
  1. 2007
Platform
  1. Windows
HOW TO INSTALL MACROs
------------------------------------
If you are new to macros, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. To use the macro, go back to the worksheet with your data on it and press ALT+F8, select the macro name (Populate_Table) from the list that appears and click the Run button. The macro will execute and perform the action(s) you asked for. If you will need to do this again in this same workbook, and if you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "Yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.

After putting the macro, and before executing it, you must change the word "master" to the name of your sheet where you have the data.
 

Watch MrExcel Video

Forum statistics

Threads
1,112,816
Messages
5,542,660
Members
410,567
Latest member
SCraig123
Top