![](/img/trans.png)
[英]excel vba - copy certain cells (as opposed to whole row) based on whether a certain cell has a certain value
[英]VBA finding whether a value exists in certain cells
我正在嘗試查找僅在這些特定單元格中是否存在值。 我已經整理了來自各種來源的代碼,但似乎無法使其正常工作。
Resources = ActiveWorkbook.Sheets("Sheet1").Range("A1,A4,A6,A8,A10")
MsgBox Application.WorksheetFunction.CountIf(Range(Resources, 0), ">0")
根據我為Resources
變量設置的Dim
值,我似乎會遇到各種錯誤,但我不確定是否要為, 0
設置?
任何幫助將非常感激。
這是您要嘗試的嗎?
Sub Sample()
Dim Resources As Range, aCell As Range
Dim n As Long
Set Resources = ActiveWorkbook.Sheets("Sheet1").Range("A1,A4,A6,A8,A10")
For Each aCell In Resources
If aCell.Value > 0 Then n = n + 1
Next
MsgBox n
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.