查找其中包含按钮的单元格

问题描述 投票:0回答:1

在我的 Excelsheet Excel Sheet 我有一行 (9),其中包含下拉按钮,可以选择总和等内容。如何使用 VBA 检查一行是否包含这些按钮?

我尝试过“HasValidation”和“If ws.Rows(i).AutoFilter”但没有成功

excel vba button
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.