Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 1
Default Need a little help with a custom function

Hi,

I need a function that scans a sheet for different identifiers and sums up the attributes of that variable within a specific date range ( from today till a specified date).

A sample list is below;

DATE DIV RIC
9/19/2011 3.6 ABAN.NS
9/12/2012 3.6 ABAN.NS
9/19/2013 4 ABAN.NS
5/3/2010 2 ABB.NS
5/2/2011 2 ABB.NS
5/2/2012 3 ABB.NS
4/29/2013 3 ABB.NS
7/17/2012 10 ABBP.NS
7/1/2013 10 ABBP.NS
9/16/2010 4 ABGS.NS
9/15/2011 4 ABGS.NS
9/13/2012 4 ABGS.NS
9/17/2013 4 ABGS.NS
9/17/2014 4 ABGS.NS
9/17/2015 4 ABGS.NS

For example, for for ABAN.NS stock, I need to sum up all values in column B whose dates fall between today and a specified date. So if I need all divs of ABAN.NS falling between today and 31-Dec-2012 this year, it should give me 3.6

I am using this specific function but this is not working;

Function dividends(ric As String, start_date As Date, end_date As Date) As Long

Dim i As Integer
Dim temp As Integer

dividends = 0

Sheets("Dividend").Activate
i = Sheets("Dividend").Range("A:A").Cells.SpecialCells (xlCellTypeConstants).Count

For temp = 2 To i
If Sheets("Dividend").Cells("F" & i) = ric And Sheets("Dividend").Range("B" & i).Value startdate And Sheets("Dividend").Range("B" & i).Value <= enddate Then

dividends = dividends + Sheets("Dividend").Range("C" & i).Value
End If
Next temp

End Function

The exact reference may not match as I have trimmed many columns in the data which are not necessary.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default Need a little help with a custom function

hi,

=SUMPRODUCT(--(A2:A16TODAY())*(A2:A16<DATE(2012,12,31))*(C2:C16 ="ABAN.NS")*(B2:B16))

--
isabelle



Le 2012-08-23 13:07, Longgamma a écrit :

Hi,

I need a function that scans a sheet for different identifiers and sums
up the attributes of that variable within a specific date range ( from
today till a specified date).

A sample list is below;

DATE DIV RIC
9/19/2011 3.6 ABAN.NS
9/12/2012 3.6 ABAN.NS
9/19/2013 4 ABAN.NS
5/3/2010 2 ABB.NS
5/2/2011 2 ABB.NS
5/2/2012 3 ABB.NS
4/29/2013 3 ABB.NS
7/17/2012 10 ABBP.NS
7/1/2013 10 ABBP.NS
9/16/2010 4 ABGS.NS
9/15/2011 4 ABGS.NS
9/13/2012 4 ABGS.NS
9/17/2013 4 ABGS.NS
9/17/2014 4 ABGS.NS
9/17/2015 4 ABGS.NS

For example, for for ABAN.NS stock, I need to sum up all values in
column B whose dates fall between today and a specified date. So if I
need all divs of ABAN.NS falling between today and 31-Dec-2012 this
year, it should give me 3.6

I am using this specific function but this is not working;

Function dividends(ric As String, start_date As Date, end_date As Date)
As Long

Dim i As Integer
Dim temp As Integer

dividends = 0

Sheets("Dividend").Activate
i =
Sheets("Dividend").Range("A:A").Cells.SpecialCells (xlCellTypeConstants).Count

For temp = 2 To i
If Sheets("Dividend").Cells("F" & i) = ric And
Sheets("Dividend").Range("B" & i).Value startdate And
Sheets("Dividend").Range("B" & i).Value <= enddate Then

dividends = dividends + Sheets("Dividend").Range("C" & i).Value
End If
Next temp

End Function

The exact reference may not match as I have trimmed many columns in the
data which are not necessary.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error when adding custom help file to custom function Sabotuer99 Excel Programming 1 July 19th 08 01:46 PM
Creating a custom function to interpret another custom engine func Ryan Excel Programming 0 March 3rd 08 07:18 PM
Add-in - add a custom function to a custom group. Spencer Hutton Excel Programming 1 December 4th 07 02:53 PM
Emulate Index/Match combo function w/ VBA custom function Spencer Hutton Excel Worksheet Functions 2 May 2nd 05 05:26 PM
Adding a custom function to the default excel function list DonutDel Excel Programming 3 November 21st 03 03:41 PM


All times are GMT +1. The time now is 03:51 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"