在我的 Excelsheet 我有一行 (9),其中包含下拉按钮,可以选择总和等内容。如何使用 VBA 检查一行是否包含这些按钮?
我尝试过“HasValidation”和“If ws.Rows(i).AutoFilter”但没有成功
Range
有Validation.Type
属性,用于下拉列表为3。
如果Range
对于单元格的任何验证
Sub valid()
Dim rng As Range
Set rng = Range("F1:F10")
On Error Resume Next
For Each cel In rng
testval = cel.Validation.Type
If Err = 0 Then
Debug.Print "Cell ", cel.Address, " has Validation"
Else
Err = 0
End If
Next cel
On Error GoTo 0
End Sub
或
dropdown
Sub valid()
Dim rng As Range
Set rng = Range("F1:F10")
On Error Resume Next
For Each cel In rng
testval = cel.Validation.Type
If testval = 3 Then
Debug.Print "Cell ", cel.Address, " has Validation dropdown"
testval = 0
End If
Next cel
On Error GoTo 0
End Sub