A Function
используется, когда нам нужно извлечь из него значение, если не нужно извлекать значение, тогда, вероятно, лучше использовать Subroutine
.
. Я изменяю ваш Function
навернуть логическое значение, которое будет False
, если выполнены условия.и я обновляю Range("P3")
на Sub
, который вызывает Function
.
Так это будет выглядеть примерно так ...
Option Explicit
Sub Change_Cell_To_False()
Dim result As String
result = active_users("4/1/2019", "4/1/2019", "4/15/2019", "4/1/2019", " 4/20/2019", "4/20/2019", "4/21/2019", 0)
If result = False Then
ActiveSheet.Range("P3") = "False"
End If
End Sub
Private Function active_users(ByVal cad_desde As Date, ByVal cad_fin As Date, ByVal last_log As Date, ByVal creacion As Date, ByVal per_desde As Date, ByVal per_fin As Date, ByVal download As Date, ByValbloq As Integer) As Boolean
If bloq = 0 Or bloq = 128 Then
If cad_fin < per_desde And last_log < per_desde Then
active_users = False
ElseIf cad_fin >= per_desde And cad_fin <= download And download <= per_fin And last_log < per_desde Then
active_users = False
Else
active_users = True
End If
End If
End Function