+ Reply to Thread
Results 1 to 2 of 2

Create macro in VBA to simulate stock returns

  1. #1
    Registered User
    Join Date
    04-02-2013
    Location
    Stavanger, Norway
    MS-Off Ver
    Excel 2010
    Posts
    2

    Question Create macro in VBA to simulate stock returns

    Dear all.

    I really need a VBA code, but I have no idea of how to write one. Please help me

    My inputs are: 1) A list of daily stock prices (date in one collumn and prices in another) and 2) a list of events (Dates in one collumn and number of shares bought in another column)

    This is what I need the code to do:

    1) Count number of events from list 2. (This list is manually created and may vary.

    2) Look up the event dates from list two in list one, and return the stoc price from those dates.

    3) Multiply the stock prices found in point two with the number of shares bought collumn in list two, and add together (Sumproduct) to obtain ONE figure. (This figure would now be the total sum payed for the stocks bought at the given dates).

    4) Return this figure in a "output cell" in excel.

    5) Randomly select dates from input list one. I need equally many dates as events. e.g. If there are three events (in input list 2) I need three randomly selected dates and return the belonging stock prices from thos dates. Number of events may change, and it is criticall that there are equally many randomly selected dates as input events.

    6) Multiply the random selected stock prices collumn from point five with number of shares bought collumn from input list two and sum together (sumproduct) and return this figure in excel.

    7) Repeat point 5&6 10 000 times in a list.

    The output from this should be a single collumn with 10 001 figures. The top one obtained from point 4 is now the actuall price a company has paid for the stocks they bought. The 10 000 next cells returns randomly simulated sums they would have to pay, if the dates of their stockpurchases were selected randomly.

    PLEASE HELP ME
    Last edited by Ajohs; 04-10-2013 at 09:44 AM.

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,028

    Re: VBA Help

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution.

    Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.

    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.
    Never use Merged Cells in Excel

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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