Consulting

Results 1 to 5 of 5

Thread: Evaluate Cell --- for Data validation Drop down list

  1. #1
    VBAX Mentor asingh's Avatar
    Joined
    Jul 2005
    Posts
    307
    Location

    Evaluate Cell --- for Data validation Drop down list

    Hi,

    How can I inspect a cell to check if it has a Data Validation List in it...???


    regards,
    asingh

  2. #2
    VBAX Tutor david000's Avatar
    Joined
    Mar 2007
    Location
    Chicago
    Posts
    276
    Location
    [vba]Option Explicit
    Option Base 1
    Sub ValList()
    Dim wb As Workbook
    Dim wks As Worksheet
    Dim ValArray As Variant
    Dim i As Integer
    Dim rng As Range
    Set wb = ActiveWorkbook
    Set wks = wb.ActiveSheet
    With wks
    On Error GoTo Msg
    ValArray = Array("Whole Number", "Decimal", "list", "Date", "Time", "Text Length", "Custom")
    Set rng = Union(.Cells.SpecialCells(xlCellTypeAllValidation), .Cells.SpecialCells(xlCellTypeAllValidation))
    With rng
    If .Areas.Count < 1 Then
    MsgBox ValArray(.Validation.Type) & vbNewLine & rng.Address
    Else
    For i = 1 To rng.Areas.Count
    MsgBox ValArray(.Areas(i).Validation.Type) & vbNewLine & rng.Areas(i).Address
    Next i
    End If
    End With
    End With
    Exit Sub
    Msg:
    MsgBox Err.Description
    End Sub

    [/vba]

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]
    Dim rng As Range

    On Error Resume Next
    Set rng = Intersect(ActiveCell, ActiveCell.SpecialCells(xlCellTypeAllValidation))
    On Error GoTo 0
    If Not rng Is Nothing Then

    MsgBox "activecell has validation"
    End If
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Sorry, missed the bit about only List

    [vba]

    Dim rng As Range

    On Error Resume Next
    Set rng = Intersect(ActiveCell, ActiveCell.SpecialCells(xlCellTypeAllValidation))
    On Error GoTo 0
    If Not rng Is Nothing Then

    If rng.Validation.Type = xlValidateList Then

    MsgBox "activecell has validation list"
    End If
    End If
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Mentor asingh's Avatar
    Joined
    Jul 2005
    Posts
    307
    Location
    thanks a lot...will give it a try..!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •