【发布时间】:2019-01-09 15:16:37
【问题描述】:
当部分(命名范围“Allowances_Credits_Range”)中的所有值都等于“N/A”时,我们希望删除整个部分的行(命名范围“Remove_Allowances_Credits”)。
例如,当 C161:C170 中的每个值都等于“N/A”时,我们希望删除第 156:171 行。如何使用 application.worksheetFunction count 和 countif 来完成此操作?
If Application.WorksheetFunction.Count(Range("Allowances_Credits_Range")) = Application.WorksheetFunction.Count(Range("Allowances_Credits_Range", "n/a")) Then
Workbooks(PharmacyPricingGuarantees2).Sheets("Pharmacy Pricing Guarantees").Range("Remove_Allowances_Credits").Delete
End If
我收到错误 1004
If Application.WorksheetFunction.Count(Range("Allowances_Credits_Range")) = Application.WorksheetFunction.Count(Range("Allowances_Credits_Range", "n/a")) Then
Workbooks(PharmacyPricingGuarantees2).Sheets("Pharmacy Pricing Guarantees").Range("Remove_Allowances_Credits").Delete
End If
删除命名范围“Remove_Allowances_Credits” 我收到错误 1004
【问题讨论】:
-
Count 只有一个参数,看来你需要 COUNTIF。
-
您是要删除行、清除值还是删除命名范围?
-
我正在尝试删除等于第 156:171 行的命名范围“Remove_Allowances_Credits”。
-
DavidN 提供的答案解决了这个问题。
标签: excel vba count delete-row countif