簡體   English   中英

對象'_global'的方法'范圍'失敗VBA訪問

[英]method 'range' of object '_global' failed vba access

正確陳述的問題

Application.WorksheetFunction.CountIf(Range("B:B-B5"), a) 

我想選擇整個列減去VBA中的單元格。 我怎樣才能做到這一點?

您可以為此編寫一個輔助函數:

Function CountIfExcept(from As range, except As range, criteria As String)
    CountIfExcept = Application.WorksheetFunction.CountIf(from, criteria) - Application.WorksheetFunction.CountIf(except, criteria)
End Function

用法:

totalCount = CountIfExcept(Range("B:B"), RANGE("B5"), "some condition")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM