If then as a VB function

TGroulx

New Member
Joined
Aug 7, 2008
Messages
6
What I am trying to do is create a tool to generate stat data using VB. I have so many records that using formulas and filters is killing me.

Here is a sample Table
Col A - Unique ID
Col B - Date 1
Col C - Date 2

I want to run a function that returns a stat (ex: average) for all records where Date 2 falls within a timeframe.

Example: Calculate Average of (Date 2 - Date 1) for records that -2 is in the month of October.

Any Help here?
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
How many records are you talking? By the sounds of it that should be a fairly straightforward array formula:

=AVERAGE(IF(MONTH(Date2Range)=10,Date2Range - Date1Range))

confirmed with Ctrl+Shift+Enter.
 
Upvote 0
How many records are you talking? By the sounds of it that should be a fairly straightforward array formula:

=AVERAGE(IF(MONTH(Date2Range)=10,Date2Range - Date1Range))

confirmed with Ctrl+Shift+Enter.


I could not get that to work, my sheet is 9000 Records by 76 Fields.

Was hoping to use VB with a user form so that I can make it intuitive for others to use. I have not used VB much beyond manipulating others macros, and simple macro records.
 
Upvote 0
Screen Shot:

Sample.xls
ABCDEFGHIJK
1NCNumberStatusDateofEventYear-MonthofEventDate-1CompleteDate-2CompleteDateMat'lReleasedfromQRBDate-4Complete,SystemDateMat'lCheckedoutofMQDate-4Complete,ComponentDate-3Complete,NonProduct
2084NCRP05000Closed10/03/0808-1010/03/0810/06/0810/06/08
3084NCRP05001Closed10/03/0808-1010/03/0810/06/0810/22/08
4084NCRP05002Closed10/03/0808-1010/03/0810/06/0811/19/08
5084NCRP05003Closed10/03/0808-1010/03/0810/06/0810/13/08
6
7
8
9
10WanttoCreateThis:
11Average-2completion
12October=if(Month(E:E)=10,average(e:e-c:c),donotcount)
13November=if(Month(E:E)=11,average(e:e-c:c),donotcount)
14December=if(Month(E:E)=12,average(e:e-c:c),donotcount)
15Etc.
16
Sample Dataset
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,061
Messages
6,122,921
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top