Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88868

Excel VBA countifs worksheetfunction

$
0
0

I am using WorksheetFunction.CountIfs to count records on Sheet2 depending on certain criteria.

The code I'm using is:

Dim wksdata As Worksheet
Dim xyz as String
Dim Time as String

Set wksdata = Sheets("Data")
Time = Date + TimeValue("08:00:00") 'Set Time value as todays date 8am
Worksheets("Calculations").Range("I15").Value = Time 'set calculations worksheet cell I15 as the time value

Worksheets("Data)").Range("U:U").NumberFormat = "dd/mm/yyyy hh:mm:ss"'converts time column to time format


 xyz = WorksheetFunction.CountIfs(wksdata.Range("I:I"), "xyz", wksdata.Range("K:K"), "C", wksdata.Range("U:U"), "<"& Worksheets("Calculations").Range("I15").Value)

If I change this to work directly in a worksheet (not VBA) then it works with the same logic.

Can anyone point out why it isn't working in VBA and and advice on how to fix it?

Thanks


Viewing all articles
Browse latest Browse all 88868


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>