+ Reply to Thread
Results 1 to 10 of 10

SUMIF Date / Average Help

  1. #1
    Registered User
    Join Date
    11-24-2008
    Location
    US - Kentucky
    Posts
    13

    SUMIF Date / Average Help

    Hi,

    I have faced with a problem with Excel when I wanted to find the average for a stock price.

    I have 2 columns:
    1st Column: Dates from 1st May 2007 till 23th December 2008 (Rows:A3:A403)
    2nd Column: Stock prices from 1st May 2007 till 23th December 2008 (Rows:B3:B403)

    So far, what I have researched is coming to the conclusion of using:
    Please Login or Register  to view this content.
    May I ask how would I modify this code so that I can input it into a macro whereby the SUMIF function can automatically sort if A3:A403 belongs to which months and then calculate the average of the stock price?

  2. #2
    Forum Contributor Kieran's Avatar
    Join Date
    10-02-2003
    Location
    Perth, Western Australia
    MS-Off Ver
    Office 2003
    Posts
    109
    bomberchia,

    it may be easier to use the pivot table functionality available in excel.

    Assuming your data has headings at the top of the columns, set the active cell to any part inside the list.
    Go to Data>PivotTable and PivotChart Report.
    When the wizard box pops up , just press finish ( it normally does everything you need)

    You will not be pesented with a new sheet and a Pivot table field list dialog.

    Grab the date field from thePivot table field list dialog and drop it over the left of the sheet. (Where it says 'drop row fields here')

    Drag the stock price from this dialog to the large box at the top left of the sheet (where it says 'drop data items here')
    At the top of the box will now be a button that says 'Sum of...' . Double click the button and change the summarize by to Average and then press OK.

    Grab the date filed from thePivot table field list dialog and drop it over the left of the sheet. (Where it says 'drop row fields here')

    Now select any of the dispalyed dates, right click and select 'Group and show detail' > group.

    Then select Months.

    You now have a table of all the month verage stock prices.
    Kieran

  3. #3
    Registered User
    Join Date
    11-24-2008
    Location
    US - Kentucky
    Posts
    13

    Smile

    Quote Originally Posted by Kieran View Post
    bomberchia,

    it may be easier to use the pivot table functionality available in excel.

    Assuming your data has headings at the top of the columns, set the active cell to any part inside the list.
    Go to Data>PivotTable and PivotChart Report.
    When the wizard box pops up , just press finish ( it normally does everything you need)

    You will not be pesented with a new sheet and a Pivot table field list dialog.

    Grab the date field from thePivot table field list dialog and drop it over the left of the sheet. (Where it says 'drop row fields here')

    Drag the stock price from this dialog to the large box at the top left of the sheet (where it says 'drop data items here')
    At the top of the box will now be a button that says 'Sum of...' . Double click the button and change the summarize by to Average and then press OK.

    Grab the date filed from thePivot table field list dialog and drop it over the left of the sheet. (Where it says 'drop row fields here')

    Now select any of the dispalyed dates, right click and select 'Group and show detail' > group.

    Then select Months.

    You now have a table of all the month verage stock prices.
    Kieran, thanks for your tip!

    What you mentioned was a method which I did also explore and it worked successfully. Unfortunately due to the request of clients, they require the solution that of a macro button, hence I'm stuck at a dead end again.

    I will upload the data screenshots in a while later to give you a clearer explaination.

    Hope to hear from you soon again!

  4. #4
    Registered User
    Join Date
    11-24-2008
    Location
    US - Kentucky
    Posts
    13
    Hi Kieran,

    I think I know what you are referring to already and I feel that it should be the way to go about it.

    just a tiny question, would the pivot table be affected when the data in A3:A403 be affected when it is updated everyday from the trading system? Can your solution still work in that way?

    Many thanks once again.

  5. #5
    Forum Contributor Kieran's Avatar
    Join Date
    10-02-2003
    Location
    Perth, Western Australia
    MS-Off Ver
    Office 2003
    Posts
    109
    bomberchia,

    The pviottable data will need to be refreshed daily.

    This can be done automatically via code, or simply by right clicking in the pivot table and selecting refresh data. It is nearly instantaneous.

  6. #6
    Registered User
    Join Date
    11-24-2008
    Location
    US - Kentucky
    Posts
    13
    Hi Kieran,

    I have tried following your instructions as given in the earlier post but I still could not make it happen.

    I have attached a sample data for reference.

    Hope to hear from you again.
    Attached Files Attached Files

  7. #7
    Forum Contributor Kieran's Avatar
    Join Date
    10-02-2003
    Location
    Perth, Western Australia
    MS-Off Ver
    Office 2003
    Posts
    109
    bomberchia,

    Is the attached file what you want?
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    11-24-2008
    Location
    US - Kentucky
    Posts
    13
    Kieran,

    Yes it is correct!

    Is it possible to use LIVE data from reuters trading to compile into a pivot table just like you have shown me? What I shared as sample was static data.

    I did try using the LIVE data and place it into pivot. What it came out was just "########".
    ?
    Any suggestions

  9. #9
    Forum Contributor Kieran's Avatar
    Join Date
    10-02-2003
    Location
    Perth, Western Australia
    MS-Off Ver
    Office 2003
    Posts
    109
    Does the information here help?

  10. #10
    Registered User
    Join Date
    11-24-2008
    Location
    US - Kentucky
    Posts
    13

    [Solved]

    Quote Originally Posted by Kieran View Post
    bomberchia,

    Is the attached file what you want?
    Yeap Yeap. Thank you so much!

+ 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