![](/img/trans.png)
[英]Excel formula: count of unique cells in column, IF corresponding row is certain value
[英]Excel (VBA needed?) Select all Cells in a row that have a certain format and are filled, then count them. Use that count in a formula
分析我為公司獲得的一些數據,我需要對單元進行計數,因此我可以使用該計數來計算公式。
CurrentRegion
不起作用。 這是需要滿足的條件。
計數的單元格必須是:
該數據是自動收集的,因此不會設置用字符串填充的字段的坐標。
(設置)行如下所示:
Description
Description
...
Time
Time
Time <- This is the data that I want to count.
Time
Time
...
Description
Time
Time
...
如果只是其中之一,我可能會明白,但是對我來說,對於VBA來說還比較陌生,這很難。
我感謝所有提示。 我不希望有人為我編寫代碼
才開始...:
Dim e As Integer
e = 0
For i = 1 To 9999
If Cells(i, 1).Value = "" Then Exit For
If IsNumeric(Cells(i, 1).Value) Then
e = e + 1
' Debug.Print Format(Cells(i, 1).Value, "h:m:s")
Else
If e <> 0 Then Debug.Print "Count = " & e
e = 0
End If
Next
宏為每個部分打印連續時間值的數量。
帶注釋的打印顯示了格式化的時間。
您需要添加代碼才能繼續...
如果還需要行范圍,請修改一些代碼:
Dim e, i, Addr1 As Integer
e = 0
For i = 1 To 9999
If Cells(i, 1).Value = "" Then Exit For
If IsNumeric(Cells(i, 1).Value) Then
If e = 0 Then Addr1 = i
e = e + 1
' Debug.Print Format(Cells(i, 1).Value, "h:m:s")
Else
If e <> 0 Then Debug.Print "Count = " & e & " - Range of Rows: " & Addr1 & " -> " & i - 1
e = 0
End If
Next
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.