2017-10-12 24 views
0

我在Excel中有一個TODO列表,其中所有任務都被分類並具有唯一的ID(1.1,1.2,2.1等)。有些任務需要完成一個或多個其他任務(即只有當1.1,1.2,1.3和2.5完成時才能啓動1.4)。用戶可以添加他自己的標準,以確定哪些任務必須完成。這可以是任何任務的組合。當一個單元格中提到的所有任務都完成時Excel條件格式

表信息: Column A - ID(1.1; 1.2; 2.1; 2.2)

Column H - 狀態(其中 「V」 表示檢查的符號,這意味着它是完成)

Column K - 預條件(用戶輸入如「3.1,2.1,4.5」作爲一個文本值)

我想測試單元中的每個ID在細胞中完成。

有沒有人知道一個很好的方法來做到這一點?

該圖顯示了任務列表的摘要。您看到第5行(ID 1.2)K欄中的單元格爲綠色,因爲所述ID已完成。列27(ID 3.2)應顯示綠色值當兩個任務2.3和3.1都完成(又名具有在列H.一個「V」的先決條件的量可以每個任務而變化。

Image of desired result

+0

您能否包含實際電子表格的屏幕截圖和期望的結果示例? – ImaginaryHuman072889

回答

0

當作爲列條件格式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 
相關問題