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!
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
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
 
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,215,737
Messages
6,126,573
Members
449,318
Latest member
Son Raphon

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top