Splitting Data Using Shared Columns

blu817

New Member
Joined
Aug 18, 2017
Messages
20
Hi
I’m hoping someone can help with this. For those who look at option chains for stocks it will make a lot of sense. I pasted a simplified version of the data below. I have a set of data when exported there are two shared columns (columns D and E) so on the left side it shows the prices for calls and on the right show the prices for puts. For example when looking at row one the 03/29/2018 expiration has 2 sets of data, the 40 strike C has a price of $1 and Put price of $40. I want to take the Put prices and add them to end of the call prices. The number of expiration day and strike’s vary which adds another layer to this. I am looking for a macro or suggestion on how I can split the data up, anything at this point would be great.



ProductCurrent PricePrevious PriceStrike PriceSeries DatesCurrent PricePrevious PriceProduct
Call11.1403/29/20184038.1Put
Call22.1413/29/20183939.1Put
Call33.1423/29/20183840.1Put
Call44.1433/29/20183741.1Put
Call55.1443/29/20183642.1Put
Call66.1453/29/20183743.1Put
Call77.1463/29/20183844.1Put
Call88.1473/29/20183945.1Put
Call99.1483/29/20183446.1Put
Call1010.1493/29/20183547.1Put
Call1111.1503/29/20183648.1Put
Call1212.1406-Apr3349.1Put
Call1313.1416-Apr3250.1Put
Call1414.1426-Apr3151.1Put
Call1515.1436-Apr3052.1Put
Call1616.1446-Apr2953.1Put
Call1717.1456-Apr2854.1Put
Call1818.1466-Apr2255.1Put
Call1919.1476-Apr3756.1Put
Call2019.1486-Apr3856.1Put
Call2119.1496-Apr3956.1Put
Call2219.1506-Apr4056.1Put

<tbody>
</tbody>
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
For those who look at option chains for stocks it will make a lot of sense.
.. and for those of us that don't (probably the vast majority of us) it makes little sense at all so you would need to spell it out in detail.
You talk about "40 strike C" What does that mean?
Row 1 has a "Put price of $40". Is that the first 40 in the row or the last 40 in the row?

Could you post the data again and show us the expected result(s) as well and explain how you got it/them manually? (My signature block below has a link for clearer ways to post your sample data)
 
Upvote 0
Sorry if the paste is all weird.

The way to read the original data would be for 03/29/2018 the 40 strike call is priced at $1 and the 40 strike put is valued at $40. Hopefully that makes more sense when the date and strike price is shared. Both call and put would expire on 03/29/2018.



ProductCurrent PricePrevious PriceStrike PriceSeries Dates
Call11.1403/29/2018
Call22.1413/29/2018
Call33.1423/29/2018
Call44.1433/29/2018
Call55.1443/29/2018
Call66.1453/29/2018
Call77.1463/29/2018
Call88.1473/29/2018
Call99.1483/29/2018
Call1010.1493/29/2018
Call1111.1503/29/2018
Put4038.1403/29/2018
Put3939.1413/29/2018
Put3840.1423/29/2018
Put3741.1433/29/2018
Put3642.1443/29/2018
Put3743.1453/29/2018
Put3844.1463/29/2018
Put3945.1473/29/2018
Put3446.1483/29/2018
Put3547.1493/29/2018
Put3648.1503/29/2018
Call1212.1406-Apr
Call1313.1416-Apr
Call1414.1426-Apr
Call1515.1436-Apr
Call1616.1446-Apr
Call1717.1456-Apr
Call1818.1466-Apr
Call1919.1476-Apr
Call2019.1486-Apr
Call2119.1496-Apr
Call2219.1506-Apr
Put3349.1406-Apr
Put3250.1416-Apr
Put3151.1426-Apr
Put3052.1436-Apr
Put2953.1446-Apr
Put2854.1456-Apr
Put2255.1466-Apr
Put3756.1476-Apr
Put3856.1486-Apr
Put3956.1496-Apr
Put4056.1506-Apr
Call2320.14020-Apr
Call2421.14120-Apr
Call2522.14220-Apr
Call2623.14320-Apr
Call2724.14420-Apr
Call2825.14520-Apr
Call2926.14620-Apr
Call3027.14720-Apr
Call3128.14820-Apr
Call3229.14920-Apr
Put3056.14020-Apr
Put3156.14120-Apr
Put3256.14220-Apr
Put3356.14320-Apr
Put3456.14420-Apr
Put3556.14520-Apr
Put3656.14620-Apr
Put3756.14720-Apr
Put3856.14820-Apr
Put3956.14920-Apr

<tbody>
</tbody>
 
Upvote 0
Assuming original data is in columns A:H and results can go in columns J:N, try this in a copy of your workbook.

Code:
Sub Call_Put()
  With Range("J2:N" & Range("A" & Rows.Count).End(xlUp).Row)
    .Value = .Offset(, -9).Value
    .Offset(.Rows.Count).Value = Application.Index(.Offset(, -6), Evaluate("row(1:" & .Rows.Count & ")"), Array(5, 3, 4, 1, 2))
    .Columns(5).EntireColumn.NumberFormat = "dd/mm/yyyy"
    .Rows(0).Value = .Offset(-1, -9).Value
    .EntireColumn.AutoFit
    .EntireColumn.Sort Key1:=.Columns(5), Order1:=xlAscending, Header:=xlYes
  End With
End Sub
 
Upvote 0
Thank you for the replying, for some reason in the previous price column its pasting dates. I tried looking at the code and can't figure it out.

ProductCurrent PricePrevious PriceStrike PriceSeries Dates
Call101/01/19004029/03/2018
Call202/01/19004129/03/2018
Call303/01/19004229/03/2018
Call404/01/19004329/03/2018
Call505/01/19004429/03/2018
Call606/01/19004529/03/2018
Call707/01/19004629/03/2018
Call808/01/19004729/03/2018
Call909/01/19004829/03/2018
Call1010/01/19004929/03/2018
Call1111/01/19005029/03/2018
Call1212/01/19004006/04/2018
Call1313/01/19004106/04/2018
Call1414/01/19004206/04/2018

<colgroup><col><col><col><col><col></colgroup><tbody>
</tbody>
 
Upvote 0
Try adding the blue line where shown
Rich (BB code):
Sub Call_Put()
  With Range("J2:N" & Range("A" & Rows.Count).End(xlUp).Row)
    .Columns(3).EntireColumn.NumberFormat = "General"
    .Value = .Offset(, -9).Value
    .Offset(.Rows.Count).Value = Application.Index(.Offset(, -6), Evaluate("row(1:" & .Rows.Count & ")"), Array(5, 3, 4, 1, 2))
    .Columns(5).EntireColumn.NumberFormat = "dd/mm/yyyy"
    .Rows(0).Value = .Offset(-1, -9).Value
    .EntireColumn.AutoFit
    .EntireColumn.Sort Key1:=.Columns(5), Order1:=xlAscending, Header:=xlYes
  End With
End Sub
 
Last edited:
Upvote 0
If you ever end up in Dallas TX let me know and I'll buy you a beer! Thanks for helping out
 
Upvote 0
If you ever end up in Dallas TX let me know and I'll buy you a beer! Thanks for helping out
No problem. .. and I'll keep that beer in mind. ;)

(I forgot to mention it, but I assume that you figured out to alter the date format in the middle line of the code to suit your US format?)
 
Upvote 0

Forum statistics

Threads
1,215,692
Messages
6,126,227
Members
449,303
Latest member
grantrob

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