473,395 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Calculating statistical measures based upon a given start and end date.

5
Hi there,

I have investment returns for stocks that I would like to calculate the mean for based upon a certain date range i.e. 1st May 2010 to 14th May 2010 (daily date to daily date) or January to March (month to month).

The spreadsheet is set up in that Sheet2 has the daily dates in "column A", "column B" has Stock_A daily returns, "column C" has Stock_B daily returns, and "column D" has Stock_C returns.

Sheet1 has user inputs i.e. Stock, StartDate, EndDate, and DataFrequency.

I would like to create a dynamic procedure that would allow the user to pick the stock, enter the start date in question, enter the end date in question, the data frequency in question, and the mean value for that period would appear in Sheet3 in cell A1 for example.

The below is me just thinking about it.

Expand|Select|Wrap|Line Numbers
  1. Dim Stock As String
  2. Dim StartDate As Date
  3. Dim EndDate As Date
  4. Dim DataFreQ As String
  5.  
  6. ' User inputs
  7. Fund = Worksheets("Sheet1").Range("A1")
  8. StartDate = Worksheets("Sheet1").Range("A2")
  9. EndDate = Worksheets("Sheet1").Range("A3")
  10. DataFrequency = Worksheets("Sheet1").Range("A4")
I’m currently studying up on John Walkenbach’s excel reference guide but it’s taking time.

I’m still learning and definitely not a VBA master yet. Hence, my main question is how do I create procedure that calculates the mean for a certain start date and end date range.

Any assistance would be much appreciated.

Thanks.
Apr 1 '12 #1

✓ answered by NeoPa

Assuming that each date only has one row of data for it in Sheet2, then once the operator selections have been made in Sheet1 you would want to follow the steps below :
  1. Use Range.Find in Column A of Sheet2 to determine the Row number of the first required date.
  2. Use Range.Find in Column A of Sheet2 (again) to determine the Row number of the last required date.
  3. Determine the column from whatever the operator enters that selects the column (I guess it must be the fund value).
  4. Now you have the actual range of cells required you can set the formula of Sheet3.A1 to :
    Expand|Select|Wrap|Line Numbers
    1. =Average({DeterminedRange})

4 1561
NeoPa
32,556 Expert Mod 16PB
Please explain (and maybe give some example data of) the layout of the data in Sheet2. [code] tags are mandatory so please don't forget to use them for showing the data.
Apr 1 '12 #2
NeoPa
32,556 Expert Mod 16PB
Assuming that each date only has one row of data for it in Sheet2, then once the operator selections have been made in Sheet1 you would want to follow the steps below :
  1. Use Range.Find in Column A of Sheet2 to determine the Row number of the first required date.
  2. Use Range.Find in Column A of Sheet2 (again) to determine the Row number of the last required date.
  3. Determine the column from whatever the operator enters that selects the column (I guess it must be the fund value).
  4. Now you have the actual range of cells required you can set the formula of Sheet3.A1 to :
    Expand|Select|Wrap|Line Numbers
    1. =Average({DeterminedRange})
Apr 1 '12 #3
Chanko
5
Thanks for the speedy resonse NeoPa.

That makes perfect sense :)
Apr 2 '12 #4
NeoPa
32,556 Expert Mod 16PB
Pleased to help Chanko. It's always easier when a member posts a question that's well expressed, as yours is.
Apr 2 '12 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: sandy | last post by:
Hi, Using Java script I am trying to create code where when you place in the start date it automatically calculates 6 months for the experations date. For example when I place 01/01/04 as the...
2
by: rong.guo | last post by:
Hi Group! I am struggling with a problem of giving a date range given the start date. Here is my example, I would need to get all the accounts opened between each month end and the first 5...
3
by: David Kuhn | last post by:
I have a query with a date field criteria of: Between And When the query is run, I am asked for the Start date and then the End Date. So far, so good. The records returned are all those in...
0
by: Ray S via .NET 247 | last post by:
Hi, I am trying to sort articles based on Start Date. Since we areusing Content Management Server I have to use ChannelItem class(and so ChannelItem.StartDate property). Earlier we were...
1
by: Mike P | last post by:
Is it possible when populating a datagrid to populate a dropdownlist column based upon the value populated to another row in the datagrid? (i.e. I have a drop down which I want to populate...
7
by: No bother | last post by:
I have a table which has, among other fields, a date field. I want to get a count of records where certain criteria are met for, say, three days in a row. For example: NumWidgets Date...
9
by: trogenone | last post by:
Hello Im new to this and need a hand. Sorry if i have posted this in the wrong area. I am working on a small database it consists of two tables: Employees & Holidays Employees field are: ...
1
by: Del | last post by:
I have a parameter query that requires the user to enter a Start Date: and End Date: and pull data between that date range. I am currently using the following parameter; Select * From mytable...
0
by: =?Utf-8?B?QW5pdGhh?= | last post by:
Hi, Currently for Announcement library a custom column "publish start date" is added and under the search result webpart changed the xslt by filtering the result based on the publish start date...
3
by: zandiT | last post by:
Hello I have an access report and im using a query to filter the report using Date parameters eg Start Date-12 May 2009 and End Date-30 September 2009. the query works perfectly. My problem is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.