Consulting

Results 1 to 3 of 3

Thread: vba sumifs

  1. #1
    VBAX Newbie
    Joined
    May 2012
    Posts
    1
    Location

    vba sumifs

    I am seeking assistance with the worksheet function sumifs to sum the contents of a column if it meets multiple criteria.


    It all works well until I introduce dates i.e. if between two dates.

    Here is the relevant parts of the code.

    [VBA]Dim objLab As Range, objPit As Range, objSamples As Range, objmDate As Range
    Dim strLab As String, strPit As String, strCost As String, strSamples As String, strsDate As String, streDate As String

    'strSamples = WorksheetFunction.SumIfs(objSamples, objLab, strLab, objPit, strPit, objmDate, ">=" & strsDate, objmDate, "<=" & streDate)
    'strCost = WorksheetFunction.SumIfs(objCost, objLab, strLab, objPit, strPit, objmDate, ">=" & strsDate, objmDate, "<=" & streDate)
    [/VBA]

    any assistance would be greatly appreciated
    Last edited by Bob Phillips; 05-09-2012 at 01:02 AM. Reason: Added VBA tags

  2. #2
    Moderator VBAX Master geekgirlau's Avatar
    Joined
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,464
    Location
    Try using SUMPRODUCT instead.

    Generally I'm not a fan of hardcoding formulas - have you thought about performing the calculations either on a hidden sheet or in a hidden column in your workbook instead?

    We are what we repeatedly do. Excellence, therefore, is not an act but a habit.
    Aristotle

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Show us the code that sets up those variables, that is probably where your problem lies.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •