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
[TABLE="width: 1099"]
<colgroup><col><col><col><col><col><col><col><col></colgroup><tbody>[TR]
[TD]Trans #[/TD]
[TD]Name[/TD]
[TD]ID #[/TD]
[TD]Minutes[/TD]
[TD]1st Change[/TD]
[TD]Subsequent Changes[/TD]
[TD]Seconds[/TD]
[TD]Outlier[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]John Smith[/TD]
[TD]66247465[/TD]
[TD]0.3[/TD]
[TD]y[/TD]
[TD] [/TD]
[TD]18[/TD]
[TD]N[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Jane Doe[/TD]
[TD]65446416[/TD]
[TD]0.6[/TD]
[TD]n[/TD]
[TD]2[/TD]
[TD]18[/TD]
[TD]N[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Jack Green[/TD]
[TD]67451678[/TD]
[TD]1[/TD]
[TD]y[/TD]
[TD] [/TD]
[TD]60[/TD]
[TD]N[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Jill Brown[/TD]
[TD]46764876[/TD]
[TD]2[/TD]
[TD]y[/TD]
[TD] [/TD]
[TD]120[/TD]
[TD]N[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]John Smith[/TD]
[TD]74161687[/TD]
[TD]2[/TD]
[TD]y[/TD]
[TD] [/TD]
[TD]120[/TD]
[TD]N[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]Jane Doe[/TD]
[TD]46872419[/TD]
[TD]2[/TD]
[TD]y[/TD]
[TD] [/TD]
[TD]120[/TD]
[TD]N[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]Jack Green[/TD]
[TD]68468761[/TD]
[TD]2[/TD]
[TD]y[/TD]
[TD] [/TD]
[TD]120[/TD]
[TD]N[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]Jill Brown[/TD]
[TD]76876417[/TD]
[TD]1[/TD]
[TD]n[/TD]
[TD]1[/TD]
[TD]60[/TD]
[TD]N[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]John Smith[/TD]
[TD]68768712[/TD]
[TD]1[/TD]
[TD]n[/TD]
[TD]1[/TD]
[TD]60[/TD]
[TD]N


[/TD]
[/TR]
</tbody>[/TABLE]

Thank you for whatever help you can offer!
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected 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
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,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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