Dim SJtempARTIST, SJtempSTATION, SJtempADD, SJtempSPINS, targetCELL As Range
Dim stationARTIST, stationSTATION As String
Sheets("STATIONS").Select
For RARTSTAT = 2 To lrARTSTAT1
stationARTIST = Worksheets("STATIONS").Cells(1, cARTIST)
stationSTATION = Worksheets("STATIONS").Cells(RARTSTAT, 2)
Set SJtempARTIST = Worksheets("TEMPDB").Range("A1:A" & lrSJIMPORT2)
Set SJtempSTATION = Worksheets("TEMPDB").Range("C1:C" & lrSJIMPORT2)
Set SJtempADD = Worksheets("TEMPDB").Range("F1:F" & lrSJIMPORT2)
Set SJtempSPINS = Worksheets("TEMPDB").Range("E1:E" & lrSJIMPORT2)
Set targetCELL = Sheets("STATIONS").Cells(RARTSTAT, cARTIST)
checkRECORD = Application.WorksheetFunction.CountIfs(SJtempSTATION, _
stationSTATION, SJtempARTIST, stationARTIST)
checkADD = Application.WorksheetFunction.CountIfs(SJtempSTATION, _
stationSTATION, SJtempARTIST, stationARTIST, SJtempADD, 1)
checkSPINS = Application.WorksheetFunction.SumIfs(SJtempSPINS, _
SJtempSTATION, stationSTATION, SJtempARTIST, stationARTIST)
checkX = InStr(1, LCase(targetCELL), "x")
checkADD = InStr(1, LCase(targetCELL), "add")
Hello guys. Well here is one part of code. Variable checkADD returns value 0 while clearly it shouldn`t, as rest of variables returning values properly. Anyway, here is more info:
checkRECORD finds and count properly 1 record. checkADD should too as it is using same method with one criteria and range more (in that F1:F column values can be either 0 either 1, and I want to count 1`s).
Ive tried with SUMIFS to, but still doesnt count anything. Ive checked ranges, and checked criteria`s and everything is fine! Ive tried without variables (with full ranges) but without luck.
So question is... why COUNTIFS doesnt work here?
Thnx in advance
Sorry guys for taking your time, mistake was mine ofc....
checkADD = Application.WorksheetFunction.CountIfs(SJtempSTATION, _
stationSTATION, SJtempARTIST, stationARTIST, SJtempADD, 1)
checkSPINS = Application.WorksheetFunction.SumIfs(SJtempSPINS, _
SJtempSTATION, stationSTATION, SJtempARTIST, stationARTIST)
checkX = InStr(1, LCase(targetCELL), "x")
checkADD = InStr(1, LCase(targetCELL), "add")
I named checkADD variable two times. It is too late I guess, I should rest a bit...