當作爲列條件格式K.
=countifs($A$1:$A$1000,$K1,$H$1:$H$1000,"v")>0
檢查與多個任務的單元格中輸入的第一部分非常簡單,如下公式將爲K5,K6,K15和工作更加困難,你可能需要將它們分成隱藏列中的單元格以檢查它們。
您可以使用自定義VBA函數檢查具有多個任務的單元。功能添加到一個VBA模塊並保存,然後在列中使用公式=canStart(K1)=True
在條件格式K.
這將檢查無限的子任務,但不會自動更新,所以你需要使用按Ctrl + Alt鍵+F9定期更新。
Function canStart(Rng As Range) As Variant
Dim arrSubtasks As Variant
Dim subTasksComplete As Boolean
If Rng.Value <> "" Then 'check if there is a subtask in the cell
If InStr(1, Rng.Value, ",") > 0 Then ' check if there is more than 1 subtask (look for a comma)
arrSubtasks = Split(Rng.Value, ",") ' create an array of all the subtasks in the cell
subTasksComplete = True ' set sub tasks as complete
For Each subTask In arrSubtasks ' loop through each subtask
If Application.WorksheetFunction.CountIfs(Range("A2:A1000"), subTask, Range("K2:K1000"), "v") = 0 Then 'if the subtask being checked is not found as complete
subTasksComplete = False ' mark subTasksComplete as false and do not continue to check the others (save some time)
Exit For
End If
Next
Else ' if there is only one subtask then check if it's complete
subTasksComplete = True
If Application.WorksheetFunction.CountIfs(Range("A2:A1000"), Rng.Value, Range("K2:K1000"), "v") = 0 Then
subTasksComplete = False
End If
End If
canStart = subTasksComplete 'set the returned value to the value of subtasksComplete
End If
End Function
您能否包含實際電子表格的屏幕截圖和期望的結果示例? – ImaginaryHuman072889