Transferring a Subset of data

rwmill9716

Well-known Member
Joined
May 20, 2006
Messages
500
Office Version
  1. 2013
Platform
  1. Windows
A subset of my data is shown in my Data Full image. Using the symbols in Column A, I need a macro that takes up to five rows on that data's symbol (starting with AMZN) and copies those rows beginning in Column U. The new table would look like Data Subset where there are 5 rows of AMZN, 3 rows of APP (only 3 entries in Column A), 5 rows of COST, 3 rows of DAL, and 4 rows of DASH. The entire data set will contain more symbols, but each symbol will be grouped, as they are in Data Full.
 

Attachments

  • Data Full.jpg
    Data Full.jpg
    253.2 KB · Views: 11
  • Data Subset.jpg
    Data Subset.jpg
    231 KB · Views: 11

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
try
Code:
Sub test()
    [t2] = "=countif(a$2:a2,a2)<=5"
    Range("a1", Range("a" & Rows.Count).End(xlUp)).Resize(, 19).AdvancedFilter 2, [t1:t2], [u1]
    [t2].Clear
End Sub
 
Upvote 0
try
Code:
Sub test()
    [t2] = "=countif(a$2:a2,a2)<=5"
    Range("a1", Range("a" & Rows.Count).End(xlUp)).Resize(, 19).AdvancedFilter 2, [t1:t2], [u1]
    [t2].Clear
End Sub
Fugi, thanks for working on this. When I run this subroutine, I get "True" in cell T2, and it stops there. Note, I call the subroutine ICSort. What does the t1:t2 do?

MrExcel.jpg
 
Upvote 0
1) How many rows do you have?
2) [t1:t2] is equivalent to Range("t1:t2") and used as criteria range in advanced filter, so T1 must be blank.

Any error? or just stopped?

Anyway, working with the picture is too hard, so it will help if you use
XL2BB - Excel Range to BBCode
or upload your workbook somewhere like Dropbox.
 
Upvote 0
I have ~1,000 rows with up to 40 symbols. No error message; it prints "True" om cell T2 and then stops. I tried to step through the macro, and it just highlights the 3rd row in yellow. I assume that it works for you if you create a dummy table. Again, thanks for your help. As it stands, I'm doing this by hand.
 
Upvote 0
1) How many rows do you have?
2) [t1:t2] is equivalent to Range("t1:t2") and used as criteria range in advanced filter, so T1 must be blank.

Any error? or just stopped?

Anyway, working with the picture is too hard, so it will help if you use
XL2BB - Excel Range to BBCode
or upload your workbook somewhere like Dropbox.
There are ~1,000 rows using ~40 symbols (both vary). Prints "TRUE" in cell T2, and there is a
TEST.xlsm
ABCDEFGHIJKLMNOPQRS
1TSM Iron CondorsL PutS PutS CallL Call1/21/20252:31 PMCT
2SymbolPrice~Exp DateLeg1Ask1Leg2Bid2Leg3Bid3Leg4Ask4BE+BE-Max ProfitMax LossAvg IVRisk/ Reward%BE ProbDays to Expire
3AMZN231.311/24/2522500.00%0.56217.50.14224.580.42708.00%0.0616.86 to 10.8620.84633
4AMZN231.311/24/2522750.00%1.03217.50.14226.610.89911.00%0.1010.24 to 10.7760.73013
5AMZN231.311/24/2523000.00%1.82217.50.14228.321.681082.00%0.166.44 to 10.6840.5833
6AMZN231.311/24/2522750.00%1.032200.20226.670.83667.00%0.128.04 to 10.7730.73013
7AMZN231.311/24/2523000.00%1.822200.20228.381.62838.00%0.195.17 to 10.6810.5833
8AMZN231.311/24/2522750.00%1.03222.50.33226.80.70430.00%0.166.14 to 10.7660.73013
9AMZN231.311/24/2523000.00%1.82222.50.33228.511.49601.00%0.254.03 to 10.6730.5833
10ANF125.431/24/2512500.00%2.251200.75123.51.50350.00%0.432.33 to 10.6220.52753
11CCL26.071/31/252600.00%0.68240.1325.450.55145.00%0.382.64 to 10.6410.516110
12DAL68.321/24/256700.00%0.72650.2766.550.45155.00%0.293.44 to 10.7330.67843
13DAL68.321/24/256800.00%1.04650.2767.230.77223.00%0.352.90 to 10.6490.54443
14DAL68.321/24/256800.00%1.04660.4667.420.58142.00%0.412.45 to 10.6240.54443
15DIS109.161/24/2510900.00%0.801050.08108.280.72328.00%0.224.56 to 10.650.52783
16DIS109.161/24/2510900.00%0.801060.14108.340.66234.00%0.283.55 to 10.640.52783
17DIS109.161/24/2510900.00%0.801070.26108.460.54146.00%0.372.70 to 10.620.52783
18DIS109.161/31/2510800.00%0.931050.30107.370.63237.00%0.273.76 to 10.6860.623210
19GM53.531/31/255300.00%1.56510.8752.310.69131.00%0.531.90 to 10.6010.543810
20NVDA139.261/24/2513600.00%0.671290.11135.440.56644.00%0.0911.50 to 10.7970.76063
21NVDA139.261/24/2513700.00%0.921290.11136.190.81719.00%0.118.88 to 10.7470.68773
22NVDA139.261/24/2513800.00%1.251290.11136.861.14786.00%0.156.89 to 10.6980.60713
23NVDA139.261/24/2513900.00%1.651290.11137.461.54846.00%0.185.49 to 10.6510.52233
24NVDA139.261/24/2513600.00%0.671300.13135.460.54546.00%0.1010.11 to 10.7960.76063
25NVDA139.261/24/2513700.00%0.921300.13136.210.79621.00%0.137.86 to 10.7460.68773
26NVDA139.261/24/2513800.00%1.251300.13136.881.12688.00%0.166.14 to 10.6970.60713
27NVDA139.261/24/2513900.00%1.651300.13137.481.52748.00%0.204.92 to 10.650.52233
28NVDA139.261/24/2513600.00%0.671310.16135.490.51449.00%0.118.80 to 10.7940.76063
29NVDA139.261/24/2513700.00%0.921310.16136.240.76524.00%0.156.89 to 10.7440.68773
30NVDA139.261/31/2513900.00%3.201382.78138.580.4258.00%0.721.38 to 10.5310.511910
31SHOP1061/24/2510500.00%0.971020.34104.370.63237.00%0.273.76 to 10.6650.6033
32SHOP1061/24/2510600.00%1.401020.34104.941.06294.00%0.362.77 to 10.6090.53
33TSM219.331/31/2520500.00%0.801950.28204.480.52948.00%0.0518.23 to 10.8840.874910
34TSM219.331/31/2520750.00%1.121950.28206.660.841166.00%0.0713.88 to 10.8440.827310
35TSM219.331/31/2521000.00%1.561950.28208.721.281372.00%0.0910.72 to 10.8010.770310
36UAL110.151/24/2510600.00%3.301032.36105.060.94206.00%0.462.19 to 10.6570.6293
37UAL110.151/24/2510700.00%3.701032.36105.661.34266.00%0.501.99 to 10.6390.59823
38UAL110.151/24/2510800.00%4.151032.36106.211.79321.00%0.561.79 to 10.6230.56713
39UAL110.151/24/2510900.00%4.601032.36106.762.24376.00%0.601.68 to 10.6060.53583
40UAL110.151/24/2511000.00%5.101032.36107.262.74426.00%0.641.55 to 10.590.50473
41UAL110.151/24/2510700.00%3.701053.05106.350.65135.00%0.482.08 to 10.6180.59823
42UAL110.151/24/2510800.00%4.151053.05106.91.10190.00%0.581.73 to 10.6010.56713
43UAL110.151/24/2510900.00%4.601053.05107.451.55245.00%0.631.58 to 10.5840.53583
44UAL110.151/24/2511000.00%5.101053.05107.952.05295.00%0.691.44 to 10.5690.50473
45UAL110.151/24/2510900.00%4.601073.80108.20.80120.00%0.671.50 to 10.5610.53583
46UAL110.151/24/2511000.00%5.101073.80108.71.30170.00%0.761.31 to 10.5450.50473
47UAL110.151/24/2511000.00%5.101084.25109.150.85115.00%0.741.35 to 10.5310.50473
Short Iron Condor
Cell Formulas
RangeFormula
Q1Q1=NOW()
R1R1=NOW()-TRUNC(NOW())
S3:S47S3=C3-TODAY()
n error message.
 

Attachments

  • ERROR.jpg
    ERROR.jpg
    10 KB · Views: 1
Upvote 0
OOps, sorry I completely missed the first row....
try
Code:
Sub test()
    [u:am].CurrentRegion.Clear
    [t2] = "=countif(a$3:a3,a3)<=5"
    Range("a2", Range("a" & Rows.Count).End(xlUp)).Resize(, 19).AdvancedFilter 2, [t1:t2], [u2]
    [t2].Clear
End Sub
 
Upvote 0

Forum statistics

Threads
1,225,738
Messages
6,186,728
Members
453,368
Latest member
positivemind

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