PDA

View Full Version : Worksheetfunction.countifs not working



flyfisher15
01-22-2014, 12:18 PM
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))

Aflatoon
01-23-2014, 01:10 AM
You don't need the first range with COUNTIFS - you only need (range,criteria) pairs:

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))