Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default setting DSUM criteria in a VBA function

How is the criteria changed?
This cause an error:
Workbooks("Tracker.xls").Sheets("Purchase").Range( "H6").Value = 1

Function getSetTotal(sSet As String) As Currency
' Return the total purchases for sSet
'
Dim wsPurchase As Worksheet
Dim rDB As Range ' Database
Dim rColumn ' Database column to sum the amount for sSet
Dim rCriteria As Range
Dim total As Currency

Set wsPurchase = Worksheets("Purchase")
Set rDB = wsPurchase.Range("dbPURCHASE")
rColumn = "Amount"
Set rCriteria = wsPurchase.Range("H5:H6")
'Workbooks("Tracker.xls").Sheets("Purchase").Range ("H6").Value = 1

total = Application.WorksheetFunction.DSum(rDB, rColumn, rCriteria)
'MsgBox "total: " & total
getSetTotal = total
End Function

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
DSum criteria Emece Excel Discussion (Misc queries) 2 November 26th 09 03:04 PM
DSum criteria Troubled Excel Worksheet Functions 2 November 8th 06 04:22 AM
HOW TO USE DSUM WITH MORE THAN ONE CRITERIA Michael H.M.Mikhail New Users to Excel 1 May 23rd 06 09:42 AM
How do I add a second criteria to the SUMIF or DSUM function? jlpwilley Excel Worksheet Functions 2 January 12th 06 04:44 PM
Criteria problems in the DSUM function AA Excel Worksheet Functions 5 January 10th 06 10:16 PM


All times are GMT +1. The time now is 09:35 AM.

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

About Us

"It's about Microsoft Excel"