Consulting

Results 1 to 2 of 2

Thread: Worksheetfunction.countifs not working

  1. #1

    Worksheetfunction.countifs not working

    I'm trying to use the below to define a single variable in an array. All of the variables within the below are defined correctly, and the below works just fine in worksheetfunction.sumifs but it returns a type mismatch using worksheetfunction.countifs.

    Please take a look and let me know where I'm going wrong.

     Batch_Array(I, Z, V, 1) = Application.WorksheetFunction.CountIfs(Sheets("Temp_Import").Range("I2:I" & Lastrow), _
                                                                                             Sheets("Temp_Import").Range("I2:I" & Lastrow), "=" & Batch_Array(I, Z, 0, 0), _
                                                                                             Sheets("Temp_Import").Range("H2:H" & Lastrow), "=" & Batch_Array(I, Z, V, 0))

  2. #2
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    You don't need the first range with COUNTIFS - you only need (range,criteria) pairs:
    [vba]
    Batch_Array(I, Z, V, 1) = Application.WorksheetFunction.CountIfs( _
    Sheets("Temp_Import").Range("I2:I" & Lastrow), "=" & Batch_Array(I, Z, 0, 0), _
    Sheets("Temp_Import").Range("H2:H" & Lastrow), "=" & Batch_Array(I, Z, V, 0))
    [/vba]
    Be as you wish to seem

Tags for this Thread

Posting Permissions

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