Copy subsequent row to same row based on multiple condition

yokeloonlo01

New Member
Joined
Jul 10, 2018
Messages
1
Hi,
Need some help if can do this in VBA or Pivot. Unable to figure out the way on this.
I have the following Data: from Column A to K for Equity Option Trading:
NoDate/TimeStrategyMethodQtyPos EffectEquityExpiry DateStrike PriceTransaction
Type
Price
17/6/2018 21:45VERTICALSELL-10TO OPENGOOGL13-Jul-181100PUT2.86
BUY10TO OPENGOOGL13-Jul-181097.5PUT2.64
27/6/2018 21:30VERTICALSELL-10TO OPENTSLA13-Jul-18280PUT2.64
BUY10TO OPENTSLA13-Jul-18277.5PUT2.34
37/5/2018 21:33VERTICALSELL-5TO OPENEL20-Jul-18135PUT0.52
BUY5TO OPENEL20-Jul-18130PUT0.27
47/5/2018 21:33VERTICALSELL-5TO OPENEL20-Jul-18135PUT0.52
BUY5TO OPENEL20-Jul-18130PUT0.27
57/4/2018 0:07VERTICALBUY10TO CLOSETSLA13-Jul-18385CALL0.33
SELL-10TO CLOSETSLA13-Jul-18400CALL0.18
67/3/2018 21:38VERTICALSELL-2TO OPENGOOGL6-Jul-181117.5PUT2.26
BUY2TO OPENGOOGL6-Jul-181115PUT1.99
77/3/2018 21:38VERTICALSELL-8TO OPENGOOGL6-Jul-181117.5PUT2.1
BUY8TO OPENGOOGL6-Jul-181115PUT1.83
86/28/18 21:36:54VERTICALSELL-10TO OPENMCD6-Jul-18152.5PUT0.56
BUY10TO OPENMCD6-Jul-18150PUT0.34
96/26/18 21:46:59VERTICALSELL-10TO OPENSPY27-Jun-18268PUT0.27
BUY10TO OPENSPY27-Jun-18265PUT0.08
106/26/18 21:45:56VERTICALBUY10TO CLOSESPY27-Jun-18268PUT0.27
SELL-10TO CLOSESPY27-Jun-18265PUT0.07
116/26/18 21:45:15VERTICALSELL-10TO OPENSPY27-Jun-18268PUT0.25
BUY10TO OPENSPY27-Jun-18265PUT0.08
126/25/18 22:37:00VERTICALSELL-10TO OPENGOOGL29-Jun-181100PUT3.08
BUY10TO OPENGOOGL29-Jun-181097.5PUT2.85
136/21/18 21:37:02VERT ROLLSELL-10TO OPENTSLA13-Jul-18385CALL12.24
BUY10TO OPENTSLA13-Jul-18400CALL8.27
BUY10TO CLOSETSLA6-Jul-18370CALL15.04
SELL-10TO CLOSETSLA6-Jul-18380CALL11.26
146/20/18 21:51:43VERTICALSELL-9TO OPENBIDU22-Jun-18250PUT0.45
BUY9TO OPENBIDU22-Jun-18247.5PUT0.29
156/20/18 21:51:43VERTICALSELL-1TO OPENBIDU22-Jun-18250PUT0.45
BUY1TO OPENBIDU22-Jun-18247.5PUT0.29

<tbody style="box-sizing: border-box;">
</tbody>


You can see that based on Column A (No), there were 15 set of trades and each set of trades can have more than one line, example:
For No 1 - 7/6/2018 21:45
We have a trade that involve Sell and Buy for GOOGL equity option that happen in a single trade, i,e., row 2 is Sell trade and row 3 is a buy trade. Note that cell C2 has no date (same as per Cell E2 and so on)
The requirement are:
1) Whether to use combination of VBA or otherwise, for combination of different value of B (Date/Time), and Column C (Vertical or Vert Roll), Column G (Equity), Column H (Expiry Date), Column D (Sell/Buy), cut and paste the Buy row to Column L to V, so we have the result like this:
Example: For 7/6/2018 @ 21.45pm, for GOOGL with expiry @ 13 Jul 2018, copy the row 2 to the right
(Scroll to the right further)
A B C D E F G H I J K L M N O P
NoExec TimeSpreadSideQtyPos EffectSymbolExpiry StrikeTypePrice
17/6/2018 21:45VERTICALSELL-10TO OPENGOOGL13-Jul-181100PUT2.86 BUY10TO OPENGOOGL13-Jul-181097.5PUT2.64

<tbody style="box-sizing: border-box;">
</tbody>

So the row 3 goes to row 2 and paste to L2 to V2

2) Note that in above data, no 13 has 4 rows (Sell- Buy- Buy-Sell) on the same date, so just arrange by Sell-Sell (A-K) and Buy-Buy (L-V) side by side based on added criteria (Column C - Vert RolL)

Any help is appreciated.
Thanks
Lo
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Bring the second up with a formula, copy down, paste as values:


Excel 2010
ABCDEFGHIJKLMNOPQRST
1NoDate/TimeStrategyMethodQtyPos EffectEquityExpiry DateStrike PriceTransactionPrice
2Type
317/6/2018 21:45VERTICALSELL-10TO OPENGOOGL13-Jul-181100PUT2.86BUY10TO OPENGOOGL432941097.5PUT2.64
4BUY10TO OPENGOOGL13-Jul-181098PUT2.64SELL-10TO OPENTSLA43294280PUT2.64
527/6/2018 21:30VERTICALSELL-10TO OPENTSLA13-Jul-18280PUT2.64BUY10TO OPENTSLA43294277.5PUT2.34
6BUY10TO OPENTSLA13-Jul-18277.5PUT2.34SELL-5TO OPENEL43301135PUT0.52
737/5/2018 21:33VERTICALSELL-5TO OPENEL20-Jul-18135PUT0.52BUY5TO OPENEL43301130PUT0.27
8BUY5TO OPENEL20-Jul-18130PUT0.27SELL-5TO OPENEL43301135PUT0.52
947/5/2018 21:33VERTICALSELL-5TO OPENEL20-Jul-18135PUT0.52BUY5TO OPENEL43301130PUT0.27
10BUY5TO OPENEL20-Jul-18130PUT0.27BUY10TO CLOSETSLA43294385CALL0.33
1157/4/2018 0:07VERTICALBUY10TO CLOSETSLA13-Jul-18385CALL0.33SELL-10TO CLOSETSLA43294400CALL0.18
Sheet11
Cell Formulas
RangeFormula
M3=D4


Then highlight column A, F5(Goto)-Special-Blanks and delete the rows:


Excel 2010
ABCDEFGHIJKLMNOPQRST
1NoDate/TimeStrategyMethodQtyPos EffectEquityExpiry DateStrike PriceTransactionPriceMethodQtyPos EffectEquityExpiry DateStrike PriceTransactionPrice
217/6/2018 21:45VERTICALSELL-10TO OPENGOOGL13-Jul-181100PUT2.86BUY10TO OPENGOOGL432941097.5PUT2.64
327/6/2018 21:30VERTICALSELL-10TO OPENTSLA13-Jul-18280PUT2.64BUY10TO OPENTSLA43294277.5PUT2.34
437/5/2018 21:33VERTICALSELL-5TO OPENEL20-Jul-18135PUT0.52BUY5TO OPENEL43301130PUT0.27
547/5/2018 21:33VERTICALSELL-5TO OPENEL20-Jul-18135PUT0.52BUY5TO OPENEL43301130PUT0.27
657/4/2018 0:07VERTICALBUY10TO CLOSETSLA13-Jul-18385CALL0.33SELL-10TO CLOSETSLA43294400CALL0.18
767/3/2018 21:38VERTICALSELL-2TO OPENGOOGL6-Jul-181117.5PUT2.26BUY2TO OPENGOOGL432871115PUT1.99
877/3/2018 21:38VERTICALSELL-8TO OPENGOOGL6-Jul-181117.5PUT2.1BUY8TO OPENGOOGL432871115PUT1.83
986/28/2018 21:36VERTICALSELL-10TO OPENMCD6-Jul-18152.5PUT0.56BUY10TO OPENMCD43287150PUT0.34
1096/26/2018 21:46VERTICALSELL-10TO OPENSPY27-Jun-18268PUT0.27BUY10TO OPENSPY43278265PUT0.08
11106/26/2018 21:45VERTICALBUY10TO CLOSESPY27-Jun-18268PUT0.27SELL-10TO CLOSESPY43278265PUT0.07
12116/26/2018 21:45VERTICALSELL-10TO OPENSPY27-Jun-18268PUT0.25BUY10TO OPENSPY43278265PUT0.08
13126/25/2018 22:37VERTICALSELL-10TO OPENGOOGL29-Jun-181100PUT3.08BUY10TO OPENGOOGL432801097.5PUT2.85
14136/21/2018 21:37VERT ROLLSELL-10TO OPENTSLA13-Jul-18385CALL12.2BUY10TO OPENTSLA43294400CALL8.27
15146/20/2018 21:51VERTICALSELL-9TO OPENBIDU22-Jun-18250PUT0.45BUY9TO OPENBIDU43273247.5PUT0.29
16156/20/2018 21:51VERTICALSELL-1TO OPENBIDU22-Jun-18250PUT0.45BUY1TO OPENBIDU43273247.5PUT0.29
Sheet11



(might have to unmerge some rows/cells)

edit: missed the multiple lines part, hang on........
 
Last edited:
Upvote 0
If you highlight A3:C33 or wherever your data ends, F5(Goto)-Special-Blanks, press the = key then the up arrow then ctrl-enter, you'll get:


Excel 2010
ABCDEFGHIJK
1NoDate/TimeStrategyMethodQtyPos EffectEquityExpiry DateStrike PriceTransactionTypePrice
217/6/2018 21:45VERTICALSELL-10TO OPENGOOGL13-Jul-181100PUT2.86
317/6/2018 21:45VERTICALBUY10TO OPENGOOGL13-Jul-181097.5PUT2.64
427/6/2018 21:30VERTICALSELL-10TO OPENTSLA13-Jul-18280PUT2.64
527/6/2018 21:30VERTICALBUY10TO OPENTSLA13-Jul-18277.5PUT2.34
637/5/2018 21:33VERTICALSELL-5TO OPENEL20-Jul-18135PUT0.52
737/5/2018 21:33VERTICALBUY5TO OPENEL20-Jul-18130PUT0.27
847/5/2018 21:33VERTICALSELL-5TO OPENEL20-Jul-18135PUT0.52
947/5/2018 21:33VERTICALBUY5TO OPENEL20-Jul-18130PUT0.27
1057/4/2018 0:07VERTICALBUY10TO CLOSETSLA13-Jul-18385CALL0.33
1157/4/2018 0:07VERTICALSELL-10TO CLOSETSLA13-Jul-18400CALL0.18
1267/3/2018 21:38VERTICALSELL-2TO OPENGOOGL6-Jul-181117.5PUT2.26
1367/3/2018 21:38VERTICALBUY2TO OPENGOOGL6-Jul-181115PUT1.99
1477/3/2018 21:38VERTICALSELL-8TO OPENGOOGL6-Jul-181117.5PUT2.1
1577/3/2018 21:38VERTICALBUY8TO OPENGOOGL6-Jul-181115PUT1.83
1686/28/2018 21:36VERTICALSELL-10TO OPENMCD6-Jul-18152.5PUT0.56
1786/28/2018 21:36VERTICALBUY10TO OPENMCD6-Jul-18150PUT0.34
1896/26/2018 21:46VERTICALSELL-10TO OPENSPY27-Jun-18268PUT0.27
1996/26/2018 21:46VERTICALBUY10TO OPENSPY27-Jun-18265PUT0.08
20106/26/2018 21:45VERTICALBUY10TO CLOSESPY27-Jun-18268PUT0.27
21106/26/2018 21:45VERTICALSELL-10TO CLOSESPY27-Jun-18265PUT0.07
22116/26/2018 21:45VERTICALSELL-10TO OPENSPY27-Jun-18268PUT0.25
23116/26/2018 21:45VERTICALBUY10TO OPENSPY27-Jun-18265PUT0.08
24126/25/2018 22:37VERTICALSELL-10TO OPENGOOGL29-Jun-181100PUT3.08
25126/25/2018 22:37VERTICALBUY10TO OPENGOOGL29-Jun-181097.5PUT2.85
26136/21/2018 21:37VERT ROLLSELL-10TO OPENTSLA13-Jul-18385CALL12.2
27136/21/2018 21:37VERT ROLLBUY10TO OPENTSLA13-Jul-18400CALL8.27
28136/21/2018 21:37VERT ROLLBUY10TO CLOSETSLA6-Jul-18370CALL15
29136/21/2018 21:37VERT ROLLSELL-10TO CLOSETSLA6-Jul-18380CALL11.3
30146/20/2018 21:51VERTICALSELL-9TO OPENBIDU22-Jun-18250PUT0.45
31146/20/2018 21:51VERTICALBUY9TO OPENBIDU22-Jun-18247.5PUT0.29
32156/20/2018 21:51VERTICALSELL-1TO OPENBIDU22-Jun-18250PUT0.45
33156/20/2018 21:51VERTICALBUY1TO OPENBIDU22-Jun-18247.5PUT0.29
Sheet11


then you can set two pivot tables next to each other and filter buys on one, sells on the other
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,536
Members
449,037
Latest member
tmmotairi

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