+ Reply to Thread
Results 1 to 8 of 8

Calculating VWAP via multi sheet indexes

  1. #1
    Registered User
    Join Date
    01-21-2014
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    19

    Calculating VWAP via multi sheet indexes

    In the attached spreadsheet, I am stuck on cell R5. The core of what the formula should be is below:

    Please Login or Register  to view this content.
    However, I want to use a combination of the INDEX, OFFSET, and INDIRECT functions to lookup the values automatically so it refreshes as additional data is added and so that I can drag the code down to the other rows. The VWAP that I am trying to calculate is Year-to-Date. So it should start on the first trading day of the year (can add a hard coded date on the Inputs sheet) and calculate until the most recent trading day.

    Can anyone please help me with this?V4.xlsm

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Calculating VWAP via multi sheet indexes

    First, let's fix the 200 slope. You might want to apply this technique to all of them in case there is less data than needed for that "size".

    Original P5 formula:

    =AVERAGE(OFFSET(INDEX(INDIRECT("'" & $A5 & "'!E:E"), MATCH($A$1, INDIRECT("'" & $A5 & "'!A:A"), 0)-199), , ,$P$2, ))

    Now let's replace that 199 with a formula that drops the number down when needed:

    MIN(MATCH($A$1, INDIRECT("'" & $A5 & "'!A:A"), 0)-1, 199)

    =AVERAGE(OFFSET(INDEX(INDIRECT("'" & $A5 & "'!E:E"), MATCH($A$1, INDIRECT("'" & $A5 & "'!A:A"), 0)-MIN(MATCH($A$1, INDIRECT("'" & $A5 & "'!A:A"), 0)-1, 199)), , ,$P$2, ))
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Calculating VWAP via multi sheet indexes

    Some sheets start on row2, others on row3. Need to all be the same.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Calculating VWAP via multi sheet indexes

    The actual question on this thread stumps me for now.

  5. #5
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Calculating VWAP via multi sheet indexes

    You could use something like (array formula !)

    Please Login or Register  to view this content.



  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Calculating VWAP via multi sheet indexes

    I was trying that initially but getting lost in the INDIRECT() addition for the sheet names and the dynamic adjustment of the rows to only include the year denoted in cell A1.

  7. #7
    Registered User
    Join Date
    01-21-2014
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    19

    Re: Calculating VWAP via multi sheet indexes

    Guys, thanks for the additional comments!

    Maybe it will help if I attached my entire spreadsheet to show the full picture. I am not opposed to adding some hard coded inputs to the Parameters sheet seen to help with calculating the VWAP. I will already be updating the dates everyday anyway.

    When combining my old spreadsheet with this new one and the query that brings in the stock data, however, I am running into a new problem. After hitting Get Bulk Quotes on the Parameters sheet, my price and returns formulas lose their reference. This is because the query is deleting its old sheet and then recreating a new one. Despite it having the same name, it doesn't pick it up. The Simple Moving Average section formula still works. I think it is a difference between the VLOOKUP formula that I used and the more advanced ones that you generously helped me with. Any ideas on how to fix this?

    Maybe after that, I can tackle the remaining cells on the right.

    Thanks again for all of the help!

    Cell C5 previously read
    Please Login or Register  to view this content.
    Cell D5 previously read
    Please Login or Register  to view this content.
    Cell E5 previously read
    Please Login or Register  to view this content.
    Cell F5 previously read
    Please Login or Register  to view this content.
    Cell G5 previously read
    Please Login or Register  to view this content.
    Cell H5 previously read
    Please Login or Register  to view this content.
    Multiple Stock Quote Downloader edit.xlsm
    Last edited by bgcm; 09-21-2015 at 06:30 PM.

  8. #8
    Registered User
    Join Date
    01-21-2014
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    19

    Re: Calculating VWAP via multi sheet indexes

    Just wanted to bump this thread up in hopes of help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Consolidate 5 sheets to 1 sheet, with several complex MATCHes and INDEXes (maybe?)
    By gaker10 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-26-2014, 10:14 AM
  2. Not all sheet indexes are working
    By Excel_vba in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-10-2013, 06:03 PM
  3. calculating multi cells using IF
    By SussexSal in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-08-2012, 09:13 AM
  4. Multi-Sheet, Multi-Table Vlookup possible?
    By cte in forum Excel General
    Replies: 6
    Last Post: 09-11-2010, 11:18 AM
  5. How to create a Multi Sheet WB from filtered Multi Sheet WB
    By CRIMEDOG in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-01-2010, 01:26 AM
  6. Calculating Values based on dates and indexes!
    By Nienaber in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-17-2010, 04:58 PM
  7. Calculating Yield on Multi Coupon Bonds
    By tim4682 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-08-2005, 05:09 PM

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