如何获取验证地址?

时间:2017-02-22 13:32:01

标签: vba excel-vba excel

有一些经过验证的细胞。我应该检查一个单元格是否有验证。如果它有验证,我应该得到它的验证范围。 有什么方法吗? 我尝试了很多公式,但是没有成功。

Sub checkForValidation()
Dim cell As Range, v As Long
adatOszlop = 9
todoszamlalo = 0
celOszlop = 15
Set lista = Sheets("Munka1").Range("R:R")

    lista.Name = "Szamok"
    For szamlalo = 4 To 25
        v = 0
        On Error Resume Next

        v = Cells(szamlalo, celOszlop).SpecialCells(xlCellTypeSameValidation).Count
        On Error GoTo 0

        If v = 0 Then
            Debug.Print "No validation"
            Cells(szamlalo, 10) = "No validation"
        Else
            Debug.Print "Has validation"
            Cells(szamlalo, 10) = "Has validation"

                If Not lista.Find(Cells(szamlalo, adatOszlop).Value) Is Nothing Then
                    Dim rng As Range
                    Dim ws As Worksheet

                    Sheets("Munka1").Cells(szamlalo, 14) = "ok"
                    Sheets("Munka1").Cells(szamlalo, celOszlop) = Cells(szamlalo, adatOszlop).Value
                Else
                     Call selectsub(Cells(szamlalo, adatOszlop).Value)
                End If
        End If
    Next
    'End
End Su

B'/ P>

1 个答案:

答案 0 :(得分:1)

这个小子测试活动单元并给出 DV 列表的范围或列出 DV 项或告诉你没有 DV

Sub IsIt()
    On Error GoTo trap
        MsgBox ActiveCell.Validation.Formula1
    On Error GoTo 0
    Exit Sub
trap:
    MsgBox "no data validation"
    On Error GoTo 0
End Sub