Determine if cell contains data validation

后端 未结 7 1416
盖世英雄少女心
盖世英雄少女心 2020-11-28 15:40

I am writing a VBA code that goes through a range of cells checking if each cell has data validation (drop down menu) and if not assign one to it from a list on another shee

7条回答
  •  执笔经年
    2020-11-28 16:29

    About 4 years later, I am looking for cell validation as well. Combining a few from the answers here, this is what I came up with:

    Option Explicit
    
    Public Sub ShowValidationInfo()
    
        Dim rngCell             As Range
        Dim lngValidation       As Long
    
        For Each rngCell In ActiveSheet.UsedRange
    
            lngValidation = 0
    
            On Error Resume Next
            lngValidation = rngCell.SpecialCells(xlCellTypeSameValidation).Count
            On Error GoTo 0
    
            If lngValidation <> 0 Then
                Debug.Print rngCell.Address
                Debug.Print rngCell.Validation.Formula1
                Debug.Print rngCell.Validation.InCellDropdown
            End If
        Next
    
    End Sub
    

提交回复
热议问题