+ Reply to Thread
Results 1 to 2 of 2

Buy/Open Date --> Sell/Close Date. VBA help needed for creating Stock/Investment Date Info

  1. #1
    Registered User
    Join Date
    01-28-2010
    Location
    earth, milky way
    MS-Off Ver
    Excel 2010
    Posts
    47

    Buy/Open Date --> Sell/Close Date. VBA help needed for creating Stock/Investment Date Info

    Book8.xlsx

    I have a list of stock transactions (and options transactions for those familiar with them). What I need to do is create a table where I can see a Stock Symbol, the Date I bought shares, and the Date I sold the last of those shares bought.

    In some scenarios I buy and sell the same stock multiple times, so I can't do simple lookup formulas. In other scenarios, I don't sell all shares on the same date, so I can't just lookup the "buy to close" date. I need to either find a way to lookup when the "buy to open" qty gets down to 0 and what date that occurs, or, lookup the last "buy to close" date before the next "buy to open" date (and if there is no next "buy to open" date, get the most recent "buy to close" date)

    In my attached example, you'll see two stocks: DB and MLNX. The DB example has a buy date for 300 shares on 1/23 and a sell date for those shares on 2/17. The next buy date is 6/26 for 500 shares and sell date of 8/17. In theory, I need a table like the one i have to the right of that information on the spreadsheet (new lines for each buy/sell combo)

    In the example for the second stock, I sell shares on two different dates, so I would need the latest sell date. However, if I go out and buy MLNX again, please be sure to account for that in the code as simply looking for MAX value won't work for what I need.

    Keep in mind, my goal is to have one macro I can run that will list all stocks, along with their open and close date

    Thanks a ton in advance. Post any questions you have for me here.

  2. #2
    Registered User
    Join Date
    01-28-2010
    Location
    earth, milky way
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: Buy/Open Date --> Sell/Close Date. VBA help needed for creating Stock/Investment Date

    bumping my thread for the first and last time

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1