PC Review


Reply
Thread Tools Rate Thread

Array computation in vba

 
 
Sam
Guest
Posts: n/a
 
      13th Apr 2010
I have a data table that has dates in column A and names in column B. If I
wanted to determine how many transactions an employee completed within a
given period, I'd use an array formula:
"=Sum(($A:$A>=StartDate)*($A:$A<=EndDate)*($B:$B=Employee)).

However I want to have a userform with a combo box for start date, another
for end date, another for employee. Then I want a label to display the number
of transactions the same as the Excel formula above. How can I code vba to
compute this?

Thanks,

Sam
 
Reply With Quote
 
 
 
 
Rick Rothstein
Guest
Posts: n/a
 
      13th Apr 2010
Assuming your controls have default names and that you are using a
CommandButton's Click event to execute your code, give this code a try...

Private Sub CommandButton1_Click()
Dim X As Long, LastRow As Long, Transactions As Double
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
For X = 1 To LastRow
With Worksheets("Sheet1")
If .Cells(X, "A").Value >= CDate(ComboBox1.Value) And _
.Cells(X, "A").Value <= CDate(ComboBox2.Value) And _
.Cells(X, "B").Value = ComboBox3.Value Then
Transactions = Transactions + 1
End If
End With
Next
Label1.Caption = Transactions
End Sub

--
Rick (MVP - Excel)



"Sam" <(E-Mail Removed)> wrote in message
news:B5B088E3-0453-4570-8152-(E-Mail Removed)...
> I have a data table that has dates in column A and names in column B. If I
> wanted to determine how many transactions an employee completed within a
> given period, I'd use an array formula:
> "=Sum(($A:$A>=StartDate)*($A:$A<=EndDate)*($B:$B=Employee)).
>
> However I want to have a userform with a combo box for start date, another
> for end date, another for employee. Then I want a label to display the
> number
> of transactions the same as the Excel formula above. How can I code vba to
> compute this?
>
> Thanks,
>
> Sam


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Age computation owen.cxy Microsoft Excel Programming 1 23rd Jun 2009 07:26 AM
computation error =?Utf-8?B?UmFqbmVlc2ggQXJvcmE=?= Microsoft Excel Misc 4 22nd Aug 2007 08:17 PM
Tax Computation anyaley via AccessMonster.com Microsoft Access Queries 1 14th May 2007 02:17 PM
Time Computation =?Utf-8?B?S2VuUA==?= Microsoft Excel Misc 2 15th Feb 2007 03:53 PM
.01 or .02 diffrence in computation Dr.How via OfficeKB.com Microsoft Excel Misc 1 30th Sep 2005 12:29 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:31 PM.