Copy multiple rows based on data to another workbook.

dilshod_k

Board Regular
Joined
Feb 13, 2018
Messages
79
Hello everyone,

I’ve workbook with data (range A to M) sorted in chronological descending order, around 100k rows.
The aim is to create code that copies all rows with the same date (dates in column B) to workbook Results.xlsm, adds sheet with name equal to that date and then does the same thing with data corresponding to the previous date. For example copy of all rows with date 12/31/2020 to a new sheet, name that sheet 12.31.2020, and go next to 12/30/2020 e.t.c. I know function how to find single row with a given date, but I could not figure out how to copy multiple rows based on certain criteria to another workbook. I would be grateful for any help. Thanks in advance.
Dilshod
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
There are 167 rows with date 1/8/2021, out of them it copies only one row to a new sheet, gives that sheet name 01.08.21 and then tries to add another sheet with the same name and gives error message.
 
Upvote 0
There are 167 rows with date 1/8/2021, out of them it copies only one row to a new sheet, gives that sheet name 01.08.21 and then tries to add another sheet with the same name and gives error message.
How I wish you could send me your file so we can resolve this once and for all. Because the code is working here.
 
Upvote 0
OrderHistVolChCopy.xlsx
ABCDEFGHIJKLM
1SymbolDateOpenHighLowCloseAdj. CloseVolumeV/SMA10SMA4SMA10SMA30Close/Change%
2OEG1/8/20213.113.953.033.43.4173077351756942885.11%0.480.291316.67%
3ACGL1/8/202136.4336.5135.6936.4436.4444498002041180118.00%35.6334.460.55%
4ACIA1/8/202177.458677.4579.679.6160435002572740523.60%73.1971.349.87%
5ADC1/8/202164.8765.5464.764.9764.971904700825480130.74%65.3765.260.29%
6ADCT1/8/202132.2433.8131.332.6832.68498800227800118.96%32.5634.123.42%
7ADI1/8/2021156.02159.81155.82156.74156.7442049001936820117.10%148.3143.980.73%
8ADP1/8/2021168.97172.38168.31171.05171.052638700135093095.32%172.33173.631.30%
9ADT1/8/20218.59.398.448.838.83126340003725010239.17%8.18.185.12%
10AJAX1/8/202111.4511.6111.4211.4611.4621400001002720113.42%11.7611.710.26%
11ALDX1/8/20218.610.458.610.3110.3134450001252110175.14%7.377.2321.72%
12ALLT1/8/202112.9614.6312.8814.3914.391335700357550273.57%11.2410.6812.51%
13AMRC1/8/202160.563.4559.4461.2861.281075000518270107.42%53.6248.572.30%
14AMX1/8/202114.9115.1114.8814.9614.9639003001797990116.93%14.714.470.74%
15ANET1/8/2021297.76307.22297.33306.12306.12110420055539098.82%290.39282.343.43%
16APWC1/8/20212.522.922.32.852.851117400208450436.05%2.282.1818.26%
17ASTC1/8/20211.972.061.92.042.041558100777460100.41%1.861.877.37%
18AVEO1/8/20217.257.77.067.517.51975600440540121.46%6.175.594.16%
19AVYA1/8/202120.9122.6620.5322.0622.0639886001159300244.05%19.5119.5311.70%
20BBL1/8/202160.2360.4559.3960.1760.1725170001151660118.55%55.652.60.75%
21BGI1/8/20210.941.50.881.181.18167689002805440497.73%0.890.8835.63%
22BIDU1/8/2021227.06241218240.25240.25227165001177059092.99%209.8178.1515.57%
23BL1/8/2021128.12132.51127.23129.69129.691742800618340181.85%131.27127.881.75%
24BL1/8/2021128.12132.51127.23129.69129.691742800618340181.85%131.27127.881.75%
25BOXL1/8/20211.731.941.651.761.76145227005149720182.01%1.61.632.92%
26BRQS1/8/20211.071.341.041.331.33392509005410030625.52%1.051.0729.13%
27BSMX1/8/20215.585.615.435.615.61499200222180124.68%5.255.311.81%
28CATM1/8/202140.542.0940.2341.0841.0847693001027230364.29%35.9732.6215.13%
29CG1/8/202131.732.2331.5132.1632.162061200941370118.96%31.4130.322.19%
30CHGG1/8/202192.7996.8992.2996.6396.632907700148094096.34%90.9284.955.93%
31CIG1/8/20212.82.982.82.882.88179643007235260148.29%2.82.666.27%
32CLIR1/8/20213.143.393.143.373.37560100236400136.93%3.12.896.31%
33CLNC1/8/20218.38.678.248.668.661249900510780144.70%7.657.645.48%
34CLPS1/8/20213.74.183.423.693.692530300557500353.87%3.163.1311.48%
35CLSN1/8/20210.830.980.780.850.8587384003525840147.84%0.770.73.66%
36CMRX1/8/20216.559.366.558.428.42203769002335170772.61%5.224.7869.08%
37CNET1/8/20212.694.752.633.093.092.02E+0826345920668.46%1.561.4965.24%
38CPSH1/8/20213.033.942.983.583.582083200620430235.77%2.812.5118.54%
39CRNT1/8/20212.973.492.963.413.413436900726270373.23%2.882.8516.78%
40CVI1/8/202116.3117.391616.2216.221364700631770116.01%15.2215.220.87%
41CWK1/8/202114.3714.3713.9414.3414.341388800644610115.45%14.6915.381.06%
42CX1/8/20215.785.865.725.765.762446150010400640135.19%5.355.250.35%
43DDD1/8/202121.0931.4519.623.5323.531.34E+0835040790281.43%13.3211.312.48%
44DM1/8/202121.0122.341920.7820.7889992003410030163.90%1817.432.36%
45DRIV1/8/202127.0127.0526.226.526.52167100880630146.09%24.4723.342.00%
46DSX1/8/20212.12.452.12.372.371110400496940123.45%1.971.8816.75%
47EDC1/8/2021107.44110.53106.01110.17110.171089200227410378.96%95.8188.757.93%
48EFV1/8/202149.4849.549.0149.4749.4729575001102570168.24%47.9947.130.30%
49EMAN1/8/20211.922.241.922.192.1941707001705230144.58%1.761.4315.87%
50ENIA1/8/20218.348.418.38.418.411365000682340100.05%8.267.972.56%
51ENV1/8/202184.6186.2984.2385.6285.621463100440140232.42%82.5281.921.70%
52ESGE1/8/202144.144.4443.8744.4344.4339623001461750171.07%42.2941.152.66%
53ESNT1/8/202147.0348.0246.5247.9247.92120030060441098.59%44.1944.481.78%
54FFIV1/8/2021193.72200.57189.02191.24191.241806500595910203.15%178.18172.616.19%
55FGNA1/8/202110.4510.7510.3510.3810.38554900241860129.43%10.2310.10.34%
56FPE1/8/202120.2420.2420.1920.2420.243110900157386097.66%20.220.110.15%
57FRBK1/8/20212.973.042.91333045800721690322.04%2.922.940.67%
58FTEK1/8/202155.874.985.765.7659291001887150214.18%4.454.2619.50%
59FTFT1/8/20219.4611.296.147.627.621.44E+0846552510208.65%2.792.5732.52%
60GNK1/8/20218.628.978.468.58.51948300623470212.49%7.657.511.55%
61GNRS1/8/202110.2510.3310.1410.310.3549000232050136.59%10.1310.030.98%
62GOCO1/8/202115.216.3715.04161625789001043510147.14%14.1813.1310.80%
63GRFS1/8/202119.2319.6519.1619.619.6872200434070100.94%18.8218.861.71%
64GRNQ1/8/20213.013.732.42.672.67302799001586768090.83%1.921.5920.27%
65GRUB1/8/202180.9282.7380.1882.4482.4432313001496480115.93%76.272.446.57%
66GSAH1/8/202111.111.7410.911.3811.3831429001485980111.50%10.9810.653.45%
67GSAT1/8/20210.570.630.480.560.561.32E+0820189640555.02%0.390.3540.00%
68HLT1/8/2021113.92115.67113.03114.16114.164065100206992096.39%109.73107.20.77%
69HOFV1/8/20211.632.241.621.941.94311199006471450380.88%1.451.422.78%
70HOLX1/8/202180.5481.878.8580.4980.493155000160543096.52%74.9373.633.23%
71HVT1/8/202130.232.8129.7930.8230.8245950023113098.81%28.8627.882.60%
72IDEX1/8/20213.473.8933.163.161.74E+0858741080196.76%2.342.26.04%
73IFMK1/8/20210.850.880.810.860.86832300273050204.82%0.80.814.88%
74ILF1/8/202130.6930.7530.2830.6130.6129949001469140103.85%29.6628.770.86%
75INFY1/8/202118.0718.6118.0218.5918.59178017007952200123.86%17.2816.225.93%
76INMD1/8/202149.7950.2548.5750.2250.2296370049009096.64%47.845.671.23%
77INSG1/8/202114.6215.6514.2115.0915.096230600314386098.18%15.1713.58.02%
78INUV1/8/20210.610.670.570.630.63115336005690110102.70%0.50.438.62%
79IPOF1/8/202114.1114.6513.331414116808005043760131.59%12.5611.657.12%
80ITRM1/8/20211.221.451.191.231.2395934003631200164.19%1.030.926.03%
81KERN1/8/202156.654.665.985.98108398003888570178.76%3.913.8121.30%
82KOMP1/8/202163.7563.8962.363.4263.42524900240220118.51%58.9355.930.97%
83KSA1/8/202131.8132.1731.5431.7531.75789300232130240.02%31.3831.250.86%
84KTRA1/8/20211.391.41.311.381.38734000358550104.71%1.351.372.99%
85LGHL1/8/20214.995.393.113.663.66236517002535360832.87%2.212.2959.13%
86LIVN1/8/202165.2367.086565.8465.841032200427920141.21%66.1262.181.37%
87LMFA1/8/20210.782.310.712.132.132.22E+0824176590818.80%0.850.74176.98%
88LOPE1/8/202190.492.3590.491.3191.31515100233210120.87%92.0590.141.12%
89LXRX1/8/20213.654.213.63.843.844977900251624097.83%3.52.94.63%
90MDGS1/8/20212.93.162.472.62.6250342004106820509.58%2.092.0913.04%
91MFH1/8/20214.415.944.034.394.3931484001150070173.76%3.393.094.77%
92MICT1/8/20212.52.672.262.412.411545700626700146.64%2.261.954.78%
93MLSS1/8/20212.252.52.22.462.461305900550940137.03%2.162.019.33%
94MPW1/8/202120.5821.1120.5521.0721.07180549006568130174.89%21.2720.742.83%
95MTLS1/8/20217279.9470.270.470.4732000291280151.30%58.0250.571.32%
96MUFG1/8/20214.74.734.664.724.7261780001605030284.91%4.484.41.29%
97MX1/8/202115.3716.8815.2616161336400406170229.02%13.8413.738.40%
98MXIM1/8/202194.4696.7193.7794.4194.4136654001586940130.97%89.0286.340.52%
99NBIX1/8/2021104113.22103.53112.07112.072644500801920229.77%98.3996.639.00%
100NEWR1/8/202171.577.5470.8575.1875.182759500659820318.22%65.8764.5815.77%
101NNOX1/8/202147.6254.747.653.2453.241653600764440116.32%48.0550.4111.80%
102NVFY1/8/20212.413.382.413.043.041868900270880589.94%2.442.2627.20%
103OCC1/8/20213.523.753.353.513.51994300259320283.43%2.862.9117.79%
104OPTT1/8/20213.093.122.772.782.7899748004557150118.88%2.842.71.09%
105OXFD1/8/202121.922.4921.8622.2922.2944011001884570133.53%18.1916.551.90%
106PAGS1/8/202154.8455.1553.7354.654.638218001695020125.47%54.551.51.49%
107PCRX1/8/202168.5972.0668.4470.1470.14107260053987098.68%61.5960.523.65%
108PDAC1/8/202110.6511.1610.5511.0111.01838600413470102.82%10.4810.184.66%
109PLAG1/8/20212.212.452.192.412.41731400266520174.43%2.212.159.55%
110PLUG1/8/202151.9855.9849.253.7853.789997560042018700137.93%37.0530.9913.72%
111PNR1/8/202155.2556.4455.1456.156.12054600802740155.95%53.0152.251.94%
112POLA1/8/20216.687.996.357.47.450024001474340239.30%5.524.8822.11%
113PRLB1/8/2021183.64195.24181185.71185.711042800434640139.92%164.56155.021.42%
114PRMW1/8/202116.1116.2815.8316.0816.0842602001745430144.08%15.9215.731.77%
115PRNT1/8/202136.8238.7836.0236.8636.86734600240920204.91%32.6531.161.26%
116PRPO1/8/20212.222.472.212.282.281514900688510120.03%2.112.195.07%
117PSTH1/8/202127.931.2127.2129.3229.3293979004157640126.04%26.9325.967.24%
118PT1/8/20211.161.211.141.211.21899900272730229.96%1.030.999.01%
119PTE1/8/20211.021.50.981.321.328672360012252530607.80%0.770.771.43%
120PVL1/8/20210.830.910.810.910.91548800208710162.95%0.780.7812.35%
121QD1/8/20211.351.681.321.621.62176409006600300167.27%1.331.3323.66%
122RBAC1/8/202110.810.8510.710.7810.781785500596470199.34%10.8810.750.56%
123RCON1/8/20211.631.941.61.921.9234228001190040187.62%1.491.3715.66%
124REI1/8/20211.141.1811.071.07109966005105510115.39%0.760.7315.05%
125RESN1/8/202145.073.994.774.7777967003561490118.92%3.232.5721.99%
126SALM1/8/20211.21.331.191.281.28893700437890104.09%1.131.098.47%
127SAN1/8/20213.353.393.313.373.3714525600762744090.44%3.193.150.30%
128SB1/8/20211.511.741.511.741.7480070040368098.35%1.371.2315.23%
129SBBP1/8/20212.853.282.853.113.111922800493230289.84%2.632.711.07%
130SBLK1/8/202110.1511.1710.1311.0811.081840000804320128.76%9.148.4612.95%
131SCHA1/8/202194.5494.8592.7193.9993.991677500635560163.94%90.4187.610.01%
132SCHE1/8/202131.8632.1431.732.1432.1462509001976450216.27%30.8430.22.23%
133SCOR1/8/20213.573.62.923.293.2934421001068950222.01%2.52.4315.85%
134SFET1/8/20211.51.571.441.491.492009800103497094.19%1.41.255.67%
135SGLB1/8/20213.33.743.173.553.552197700685040220.81%3.242.985.34%
136SGOC1/8/20211.642.21.581.991.993536600177314099.45%1.411.2631.79%
137SLRX1/8/20211.081.221.041.181.182882800147114095.96%0.990.948.26%
138SNDR1/8/202122.1322.6822.1322.2422.241313600627080109.48%21.0820.940.77%
139SNY1/8/202148.1548.4747.8248.4548.4545042002219720102.92%48.2648.720.75%
140SPEM1/8/202143.7544.1343.5644.1344.1350290001480250239.74%42.4541.532.08%
141SPMB1/8/202126.4826.4826.4426.4626.462333200973030139.79%26.4426.410.04%
142SPNV1/8/202111.3512.510.7511.0311.031222100512750138.34%11.0410.820.27%
143SPOT1/8/2021335354.6333.29353.11353.112199000899720144.41%322.15320.16.56%
144ST1/8/202160.2861.6455.6856.3856.381868000839250122.58%53.4151.160.46%
145STIM1/8/202112.6513.0512.212.8912.8940410020532096.81%11.229.716.79%
146STNG1/8/202112.7814.0512.6713.6313.6330227001476500104.72%11.7211.828.52%
147STPK1/8/202123.0129.2822.1625.4925.4951009002052070148.57%21.0617.179.35%
148TBF1/8/202116.3816.4616.3316.3816.381624600682940137.88%15.9415.840.24%
149TGA1/8/20211.011.150.991.141.141004400404290148.44%0.970.8514.00%
150THMO1/8/20212.32.532.262.472.472805700918160205.58%2.182.249.29%
151TLK1/8/202125.4525.6225.2125.5225.521446700351870311.15%24.323.783.07%
152TRIP1/8/202132.536.1732.3735.6535.6561325002729370124.69%29.4928.4311.51%
153TRXC1/8/20210.951.250.91.161.164524470021394790111.48%0.810.6328.89%
154TUFN1/8/202113.0214.712.9714.3914.39566300216110162.04%12.6810.7610.69%
155TWOU1/8/202141.845.5641.7444.0644.062208600113417094.73%40.7837.076.00%
156TYHT1/8/20213.343.893.253.823.821621900460500252.20%3.183.2314.71%
157UAMY1/8/20210.640.760.620.670.67117281005040650132.67%0.550.476.35%
158UNP1/8/2021218221.28216.99218.82218.823922900204647091.69%207.75204.592.87%
159VERI1/8/202133.0138.8432.2138.4538.4524749001029150140.48%29.6127.7320.42%
160VICI1/8/202125.1125.972525.6725.6793078003504260165.61%25.3325.43.09%
161VONV1/8/2021123.65123.83122.29123.53123.53415500203300104.38%120.14118.590.09%
162VSTM1/8/20212.342.552.312.532.5364496002733770135.92%2.252.228.12%
163WBS1/8/202148.9248.9246.6747.7347.7398710050078097.11%43.6241.781.55%
164WRB1/8/202167.0467.2465.4366.3666.362421800886360173.23%65.8765.730.53%
165XAN1/8/20214.034.353.864.34.31007400469790114.44%3.993.939.14%
166ZEN1/8/2021144.33149.76144.33149.37149.37185350094112096.95%141.81138.343.49%
167ZLAB1/8/2021142.88149.64141.05145.84145.84615700296100107.94%134.29120.874.31%
168ZYME1/8/202153.7957.0553.556.8156.81801800319770150.74%50.4651.816.11%
169ACEV1/7/202111.881211.4812122081600797710160.95%10.5710.192.65%
170ACTG1/7/20213.924.43.914.224.2272000037709090.94%4.023.848.21%
171ADTX1/7/20212.172.412.162.352.351823000665200174.05%2.172.099.30%
172AEHL1/7/20212.653.372.643.333.332838000894650217.22%2.562.4128.08%
173AFI1/7/20213.844.683.794.654.65856400279870206.00%3.893.6524.66%
174AFMD1/7/20216.226.485.996.446.442491800128366094.12%6.126.128.78%
175ALDX1/7/20217.328.547.058.478.473962300945030319.28%7.087.1126.42%
176ALGM1/7/202128.2531.1528.1629.9429.941627500787750106.60%26.4126.166.66%
177ALKS1/7/202119.8121.1119.5820.5920.5933435001309200155.38%20.4520.125.59%
178ALLT1/7/202110.7712.8610.7712.7912.79833200231330260.18%10.9210.5319.53%
179ALNY1/7/2021133.62140132.03139.4139.41072700490320118.78%132.36131.99.91%
180AMRH1/7/20214.025.113.714.794.7966413002388350178.07%6.186.3121.57%
181ANGO1/7/202116.5119.5216.518.5718.571236400358750244.64%15.2214.6914.70%
182ANY1/7/20211.522.351.492.232.235200800834640523.12%1.581.648.67%
183APHA1/7/20218.779.398.558.598.592156790010453450106.32%7.47.712.38%
184ARTL1/7/202111.10.93117902400401671096.74%0.760.6712.87%
185ASH1/7/202186.0187.4685.0687.287.21035600439790135.48%80.6377.732.05%
186ASHR1/7/202142.7743.1242.6543.1143.1165519002994180118.82%40.1938.972.45%
187ATH1/7/202146.7646.8545.9446.2146.212044400908710124.98%43.1543.580.43%
188ATHX1/7/20211.812.121.81.971.9757684002655820117.20%1.831.868.84%
189AVEO1/7/20216.47.246.47.217.21941700379630148.06%6.015.5214.26%
190AVNT1/7/20214546.3844.2445.745.71125500489400129.98%41.0639.34.43%
191AVTR1/7/202128.6329.4728.6129.2429.2495657003878570146.63%27.5527.193.61%
192AXL1/7/20218.929.898.869.769.7645656001921590137.59%8.498.1912.57%
193BDSI1/7/20214.554.994.524.874.871762100742840137.21%4.344.218.22%
194BE1/7/202133.7235.7432.533.5633.569003600450572099.83%29.3827.2810.32%
195BEAT1/7/202171.8872.471.8572.3872.38182340093652094.70%72.0364.010.60%
196BL1/7/2021127.74129.49126.59127.46127.4696920049636095.26%132.04127.310.64%
197BL1/7/2021127.74129.49126.59127.46127.4696920049636095.26%132.04127.310.64%
198BLI1/7/202190.4491.718789.0689.061048000517840102.38%92.5588.531.44%
199BOXL1/7/20211.61.791.521.711.71147139003898720277.40%1.591.6212.50%
200BRFS1/7/20214.034.113.994.094.0983732003274810155.69%4.214.251.24%
201BRQS1/7/202111.111.031.0342176001599540163.68%1.021.063.00%
202CAH1/7/202155.2156.5655.0656.3156.3133446001637710104.22%53.6954.082.27%
203CARR1/7/202140.4141.194041.0941.0977719003813720103.79%38.2537.872.60%
204CBAT1/7/20218.778.87.317.727.723927720012983520202.52%5.916.0220.62%
205CBRE1/7/202160.8161.6360.4361.561.52782300143494093.90%61.6963.211.47%
206CCNC1/7/20212.453.32.342.792.793599300919920291.26%1.981.7625.11%
207CCX1/7/202110.410.8910.3810.5310.5358305001465310297.90%10.3910.231.74%
208CDEV1/7/20211.792.061.751.991.99130894006111430114.18%1.631.5516.37%
209CFX1/7/202140.5641.0340.1440.5940.592715500879720208.68%37.9137.311.00%
210CHRS1/7/202117.3618.0817.1617.8917.892210900915210141.57%17.2217.834.01%
211CIBR1/7/202143.6744.4243.3344.3544.352986400956440212.24%44.2941.592.64%
212CIK1/7/20213.143.183.143.173.1735590001657490114.72%3.173.160.96%
213CLPS1/7/20213.143.493.13.313.31745000325980128.54%3.093.116.77%
214CNET1/7/20211.62.141.511.871.87428445006149090596.76%1.381.4434.53%
215COF1/7/2021108.65111.54108110.73110.734795700242576097.70%100.0794.663.12%
216CONX1/7/202110.1210.1910.110.1610.16569800241270136.17%10.1810.180.20%
217COWN1/7/202126.9228.4726.9228.3228.32766600323120137.25%26.3825.796.07%
218CP1/7/2021361.72371.38358.95370.19370.1947530024506093.95%349.87338.432.72%
219CPST1/7/202112.8515.2812.613.813.81007700364490176.47%10.88.7920.00%
220CRH1/7/202147.0747.9346.9347.647.6715600313940127.94%43.4941.762.04%
221CRON1/7/20219.129.378.788.818.8110473500526845098.80%7.638.011.85%
222CSLT1/7/20211.451.781.451.611.611678100771960117.38%1.381.2811.03%
223CTLT1/7/2021106.82108.8106.52108.57108.571824500888340105.38%104.6499.762.19%
224CUBE1/7/202132.9633.1632.5833.1633.162454700123267099.14%33.0532.610.76%
225CYRN1/7/20211.071.331.051.191.192612800580920349.77%1.061.0414.42%
226CYTK1/7/202121.3621.7320.9521.5321.532010100791950153.82%20.6919.471.03%
227DAC1/7/202124.7728.1124.7727.3627.361183600583320102.91%22.2817.9812.41%
228DD1/7/202177.9780.9477.9780.8880.8819333900994243094.46%72.0868.444.03%
229DDD1/7/202112.3625.3312.3622.9622.961.94E+0824034550705.37%12.1910.81104.27%
230DGRW1/7/202154.0554.4953.954.3954.39785200312400151.34%53.6253.250.85%
Sheet1
 
Upvote 0
It is only part of the file as there is limitation to the number of cells that may be copied. I assume if the code will be able to create 2 sheets with all rows copied, it will work with the rest of the data.
 
Upvote 0
It is only part of the file as there is limitation to the number of cells that may be copied. I assume if the code will be able to create 2 sheets with all rows copied, it will work with the rest of the data.
Hello Dilshod,
Finally, this should work. The problem was the Date has Time element hence they are not unique. I have added lines of code that resolves that.

VBA Code:
Sub CopySameDate()
x = Format([B2], "dd-mm-yy")
Application.ScreenUpdating = False
With Sheet1 ' Replace this with your data sheet code name or worksheet name
    a_du = .Range("B2:B" & .Cells(Rows.Count, 1).End(xlUp).Row)
    For d = 1 To UBound(a_du)
        a_du(d, 1) = CDate(WorksheetFunction.Text(a_du(d, 1), "dd-mmm-yy"))
    Next d
    .Range("B2").Resize(UBound(a_du)) = a_du
    
    .Range("XFD1") = .Range("B1").Value
    a_su = DistinctVals(.Range("B2:B" & .Cells(Rows.Count, 1).End(xlUp).Row)) ' Assumes your date value is in Column A
    For J = 1 To UBound(a_su)
        .Range("XFD2") = a_su(J, 1)
        Sheets.Add(, Sheets(Sheets.Count)).Name = Format(a_su(J, 1), "mm.dd.yy")
        .Range("A1").CurrentRegion.AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=.Range("XFD1:XFD2"), _
        CopyToRange:=ActiveSheet.Range(Cells(1, 1), Cells(1, .Range("A1").CurrentRegion.Columns.Count)), Unique:=False
    Next J
    .Range("XFD1:XFD2").Clear
End With
Erase a_su
End Sub
Function DistinctVals(a, Optional col = 1)
    Dim i&, v: v = a
    With CreateObject("Scripting.Dictionary")
        For i = 1 To UBound(v): .Item(v(i, col)) = 1: Next i
        DistinctVals = Application.Transpose(.Keys)
    End With
End Function
 
Upvote 0
Hello Olukunle,

It does work perfectly well! Thank you very much. Highly appreciate your efforts.
Dilshod
 
Upvote 0

Forum statistics

Threads
1,214,915
Messages
6,122,212
Members
449,074
Latest member
cancansova

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