Create new Table(s) with specific data from existing table

kapvg

New Member
Joined
Jun 30, 2018
Messages
25
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi,

I want to create new tables (1 for each day of the week) from an existing table.
The existing table has data in the below format.
DatedDayB1B2B3B4B5B6B7B8B9B10B11B12
7/1/2021Thursday0.690.720.751.010.821.110.710.910.621.440.720.84
7/2/2021Friday0.690.740.761.010.821.160.710.910.641.460.720.86
7/6/2021Tuesday0.730.810.821.090.911.230.760.940.741.660.810.97
7/7/2021Wednesday0.740.850.841.110.931.260.770.960.741.660.830.99
7/8/2021Thursday0.760.850.871.130.941.320.851.010.741.690.861.14
7/9/2021Friday0.760.850.891.180.951.350.851.020.751.690.861.14
7/10/2021Saturday0.760.850.891.170.951.360.851.010.741.690.861.12
7/11/2021Sunday0.760.840.91.180.941.350.851.010.751.670.851.12
7/12/2021Monday0.760.860.91.180.951.360.851.020.761.70.871.14
7/13/2021Tuesday0.770.860.921.180.971.360.861.030.761.70.881.14
7/14/2021Wednesday0.770.860.921.190.981.380.881.040.771.70.891.13
7/15/2021Thursday0.780.860.941.190.971.40.891.050.771.690.91.14
7/16/2021Friday0.790.860.951.220.961.420.891.050.781.710.91.14
7/17/2021Saturday0.780.860.941.210.981.410.891.050.781.710.91.13
7/18/2021Sunday0.420.550.570.790.540.790.470.560.370.770.460.53
7/19/2021Monday0.570.770.70.950.720.940.650.770.571.260.620.65
7/20/2021Tuesday0.580.790.720.990.740.960.670.770.571.270.630.68
7/21/2021Wednesday0.620.80.721.010.7510.690.810.581.340.660.76
7/22/2021Thursday0.610.810.721.050.781.010.70.820.591.340.690.78
7/23/2021Friday0.610.840.721.060.791.010.710.830.61.350.710.79
7/24/2021Saturday0.620.840.721.080.7910.70.830.611.350.720.8
7/25/2021Sunday0.620.840.731.090.791.010.690.830.611.350.720.8
7/26/2021Monday0.620.850.731.090.81.010.70.840.621.370.730.82
7/27/2021Tuesday0.630.860.741.090.81.020.720.860.621.380.730.85
7/28/2021Wednesday0.670.890.771.120.851.030.760.920.661.420.770.87


There are no formulae or anything else in the data table.
Any suggestion on how I can use VBA to create 7 new tables (1 for each day of the week) with the corresponding data?

Thanks!!
~kg
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Here's a formula solution if this suits, note that I converted your data to an excel table, so each table will update automatically;

Just ensure there is enough rows for the Filter function to spill the corresponding data;

Book1
ABCDEFGHIJKLMN
1DatedDayB1B2B3B4B5B6B7B8B9B10B11B12
21/07/2021Thursday0.690.720.751.010.821.110.710.910.621.440.720.84
32/07/2021Friday0.690.740.761.010.821.160.710.910.641.460.720.86
46/07/2021Tuesday0.730.810.821.090.911.230.760.940.741.660.810.97
57/07/2021Wednesday0.740.850.841.110.931.260.770.960.741.660.830.99
68/07/2021Thursday0.760.850.871.130.941.320.851.010.741.690.861.14
79/07/2021Friday0.760.850.891.180.951.350.851.020.751.690.861.14
810/07/2021Saturday0.760.850.891.170.951.360.851.010.741.690.861.12
911/07/2021Sunday0.760.840.91.180.941.350.851.010.751.670.851.12
1012/07/2021Monday0.760.860.91.180.951.360.851.020.761.70.871.14
1113/07/2021Tuesday0.770.860.921.180.971.360.861.030.761.70.881.14
1214/07/2021Wednesday0.770.860.921.190.981.380.881.040.771.70.891.13
1315/07/2021Thursday0.780.860.941.190.971.40.891.050.771.690.91.14
1416/07/2021Friday0.790.860.951.220.961.420.891.050.781.710.91.14
1517/07/2021Saturday0.780.860.941.210.981.410.891.050.781.710.91.13
1618/07/2021Sunday0.420.550.570.790.540.790.470.560.370.770.460.53
1719/07/2021Monday0.570.770.70.950.720.940.650.770.571.260.620.65
1820/07/2021Tuesday0.580.790.720.990.740.960.670.770.571.270.630.68
1921/07/2021Wednesday0.620.80.721.010.7510.690.810.581.340.660.76
2022/07/2021Thursday0.610.810.721.050.781.010.70.820.591.340.690.78
2123/07/2021Friday0.610.840.721.060.791.010.710.830.61.350.710.79
2224/07/2021Saturday0.620.840.721.080.7910.70.830.611.350.720.8
2325/07/2021Sunday0.620.840.731.090.791.010.690.830.611.350.720.8
2426/07/2021Monday0.620.850.731.090.81.010.70.840.621.370.730.82
2527/07/2021Tuesday0.630.860.741.090.81.020.720.860.621.380.730.85
2628/07/2021Wednesday0.670.890.771.120.851.030.760.920.661.420.770.87
27
28MondayDayB1B2B3B4B5B6B7B8B9B10B11B12
2912/07/2021Monday0.760.860.91.180.951.360.851.020.761.70.871.14
3019/07/2021Monday0.570.770.70.950.720.940.650.770.571.260.620.65
3126/07/2021Monday0.620.850.731.090.81.010.70.840.621.370.730.82
32
33TuesdayDayB1B2B3B4B5B6B7B8B9B10B11B12
346/07/2021Tuesday0.730.810.821.090.911.230.760.940.741.660.810.97
3513/07/2021Tuesday0.770.860.921.180.971.360.861.030.761.70.881.14
3620/07/2021Tuesday0.580.790.720.990.740.960.670.770.571.270.630.68
3727/07/2021Tuesday0.630.860.741.090.81.020.720.860.621.380.730.85
Sheet1
Cell Formulas
RangeFormula
A29:N31A29=FILTER(Table1[#Data],Table1[Day]=$A$28,"")
A34:N37A34=FILTER(Table1[#Data],Table1[Day]=$A$33,"")
Dynamic array formulas.
 
Upvote 0
Here's a formula solution if this suits, note that I converted your data to an excel table, so each table will update automatically;

Just ensure there is enough rows for the Filter function to spill the corresponding data;

Book1
ABCDEFGHIJKLMN
1DatedDayB1B2B3B4B5B6B7B8B9B10B11B12
21/07/2021Thursday0.690.720.751.010.821.110.710.910.621.440.720.84
32/07/2021Friday0.690.740.761.010.821.160.710.910.641.460.720.86
46/07/2021Tuesday0.730.810.821.090.911.230.760.940.741.660.810.97
57/07/2021Wednesday0.740.850.841.110.931.260.770.960.741.660.830.99
68/07/2021Thursday0.760.850.871.130.941.320.851.010.741.690.861.14
79/07/2021Friday0.760.850.891.180.951.350.851.020.751.690.861.14
810/07/2021Saturday0.760.850.891.170.951.360.851.010.741.690.861.12
911/07/2021Sunday0.760.840.91.180.941.350.851.010.751.670.851.12
1012/07/2021Monday0.760.860.91.180.951.360.851.020.761.70.871.14
1113/07/2021Tuesday0.770.860.921.180.971.360.861.030.761.70.881.14
1214/07/2021Wednesday0.770.860.921.190.981.380.881.040.771.70.891.13
1315/07/2021Thursday0.780.860.941.190.971.40.891.050.771.690.91.14
1416/07/2021Friday0.790.860.951.220.961.420.891.050.781.710.91.14
1517/07/2021Saturday0.780.860.941.210.981.410.891.050.781.710.91.13
1618/07/2021Sunday0.420.550.570.790.540.790.470.560.370.770.460.53
1719/07/2021Monday0.570.770.70.950.720.940.650.770.571.260.620.65
1820/07/2021Tuesday0.580.790.720.990.740.960.670.770.571.270.630.68
1921/07/2021Wednesday0.620.80.721.010.7510.690.810.581.340.660.76
2022/07/2021Thursday0.610.810.721.050.781.010.70.820.591.340.690.78
2123/07/2021Friday0.610.840.721.060.791.010.710.830.61.350.710.79
2224/07/2021Saturday0.620.840.721.080.7910.70.830.611.350.720.8
2325/07/2021Sunday0.620.840.731.090.791.010.690.830.611.350.720.8
2426/07/2021Monday0.620.850.731.090.81.010.70.840.621.370.730.82
2527/07/2021Tuesday0.630.860.741.090.81.020.720.860.621.380.730.85
2628/07/2021Wednesday0.670.890.771.120.851.030.760.920.661.420.770.87
27
28MondayDayB1B2B3B4B5B6B7B8B9B10B11B12
2912/07/2021Monday0.760.860.91.180.951.360.851.020.761.70.871.14
3019/07/2021Monday0.570.770.70.950.720.940.650.770.571.260.620.65
3126/07/2021Monday0.620.850.731.090.81.010.70.840.621.370.730.82
32
33TuesdayDayB1B2B3B4B5B6B7B8B9B10B11B12
346/07/2021Tuesday0.730.810.821.090.911.230.760.940.741.660.810.97
3513/07/2021Tuesday0.770.860.921.180.971.360.861.030.761.70.881.14
3620/07/2021Tuesday0.580.790.720.990.740.960.670.770.571.270.630.68
3727/07/2021Tuesday0.630.860.741.090.81.020.720.860.621.380.730.85
Sheet1
Cell Formulas
RangeFormula
A29:N31A29=FILTER(Table1[#Data],Table1[Day]=$A$28,"")
A34:N37A34=FILTER(Table1[#Data],Table1[Day]=$A$33,"")
Dynamic array formulas.
Thanks for this but I am looking at a VBA solution primarily coz the main data table is also something that I am creating via a VBA and thus it will increase in size overtime.

I was able to find VBA code snippets for copying the data in a Table via VBA but am unable to figure out how to create new tables only with data for specific days of the week. Any help would be great!!!

thanks!!
 
Upvote 0
My VBA knowledge is limited, maybe this. I added this to a shape so that once a day has been selected (A29) I can run the macro;

VBA Code:
Sub RectangleRoundedCorners1_Click()

Dim rg As Range
Set rg = ThisWorkbook.Worksheets("Sheet1").Range("A31").CurrentRegion

Application.ScreenUpdating = False

    rg.Offset(1).ClearContents

Dim rgdata As Range, rgcriteria As Range, rgOutput As Range

    Set rgdata = ThisWorkbook.Worksheets("Sheet1").Range("A1").CurrentRegion
        Set rgcriteria = ThisWorkbook.Worksheets("Sheet1").Range("A28").CurrentRegion
    Set rgOutput = ThisWorkbook.Worksheets("Sheet1").Range("A31").CurrentRegion

    rgdata.AdvancedFilter xlFilterCopy, rgcriteria, rgOutput

Application.ScreenUpdating = True

End Sub


Create new Tables with specific data from existing table_kapvg.xlsx
ABCDEFGHIJKLMN
1DatedDayB1B2B3B4B5B6B7B8B9B10B11B12
21/07/2021Thursday0.690.720.751.010.821.110.710.910.621.440.720.84
32/07/2021Friday0.690.740.761.010.821.160.710.910.641.460.720.86
46/07/2021Tuesday0.730.810.821.090.911.230.760.940.741.660.810.97
57/07/2021Wednesday0.740.850.841.110.931.260.770.960.741.660.830.99
68/07/2021Thursday0.760.850.871.130.941.320.851.010.741.690.861.14
79/07/2021Friday0.760.850.891.180.951.350.851.020.751.690.861.14
810/07/2021Saturday0.760.850.891.170.951.360.851.010.741.690.861.12
911/07/2021Sunday0.760.840.91.180.941.350.851.010.751.670.851.12
1012/07/2021Monday0.760.860.91.180.951.360.851.020.761.70.871.14
1113/07/2021Tuesday0.770.860.921.180.971.360.861.030.761.70.881.14
1214/07/2021Wednesday0.770.860.921.190.981.380.881.040.771.70.891.13
1315/07/2021Thursday0.780.860.941.190.971.40.891.050.771.690.91.14
1416/07/2021Friday0.790.860.951.220.961.420.891.050.781.710.91.14
1517/07/2021Saturday0.780.860.941.210.981.410.891.050.781.710.91.13
1618/07/2021Sunday0.420.550.570.790.540.790.470.560.370.770.460.53
1719/07/2021Monday0.570.770.70.950.720.940.650.770.571.260.620.65
1820/07/2021Tuesday0.580.790.720.990.740.960.670.770.571.270.630.68
1921/07/2021Wednesday0.620.80.721.010.7510.690.810.581.340.660.76
2022/07/2021Thursday0.610.810.721.050.781.010.70.820.591.340.690.78
2123/07/2021Friday0.610.840.721.060.791.010.710.830.61.350.710.79
2224/07/2021Saturday0.620.840.721.080.7910.70.830.611.350.720.8
2325/07/2021Sunday0.620.840.731.090.791.010.690.830.611.350.720.8
2426/07/2021Monday0.620.850.731.090.81.010.70.840.621.370.730.82
2527/07/2021Tuesday0.630.860.741.090.81.020.720.860.621.380.730.85
2628/07/2021Wednesday0.670.890.771.120.851.030.760.920.661.420.770.87
27
28Day
29Wednesday
30
31DatedDayB1B2B3B4B5B6B7B8B9B10B11B12
327/07/2021Wednesday0.740.850.841.110.931.260.770.960.741.660.830.99
3314/07/2021Wednesday0.770.860.921.190.981.380.881.040.771.70.891.13
3421/07/2021Wednesday0.620.80.721.010.7510.690.810.581.340.660.76
3528/07/2021Wednesday0.670.890.771.120.851.030.760.920.661.420.770.87
Sheet1
Cells with Data Validation
CellAllowCriteria
A29List=$B$9:$B$15
 
Upvote 0

Forum statistics

Threads
1,216,138
Messages
6,129,099
Members
449,486
Latest member
malcolmlyle

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