' ListWksDVCellSettings()
' o Inserts a new worksheet in the current workbook
' o Identifies every DV cell in the active sheet
' o On the new sheet, it lists:
' ...Parent sheet name and cell address
' ...DV Type
' ...Formula1
' ...Formula2
Sub ListWksDVCellSettings()
Dim wksCurr As Worksheet
Dim wksNew As Worksheet
Dim cCell As Range
Dim cStartCell As Range
Dim Ctr As Long
Dim DVType As Integer
Dim DVTypeDesc As String
Set wksCurr = ActiveSheet
Set wksNew = Worksheets.Add
Set cStartCell = wksNew.Range("A1")
On Error GoTo errTrap
Ctr = 1
wksCurr.Activate
wksCurr.Cells(1, 1).SpecialCells(xlCellTypeAllValidation).Select
With cStartCell
.Value = "Worksheet: " & wksCurr.Name
.Offset(RowOffset:=Ctr, ColumnOffset:=0).Value = "Cell Ref"
.Offset(RowOffset:=Ctr, ColumnOffset:=1).Value = "DV Type"
.Offset(RowOffset:=Ctr, ColumnOffset:=2).Value = "Formula1"
.Offset(RowOffset:=Ctr, ColumnOffset:=3).Value = "Formula2"
Ctr = Ctr + 1
For Each cCell In Selection
.Offset(RowOffset:=Ctr, ColumnOffset:=0).Value = cCell.Parent.Name & "!" & cCell.Address
DVType = cCell.Validation.Type
' Determine validation type
' xlValidateInputOnly.....0
' xlValidateWholeNumber...1
' xlValidateDecimal.......2
' xlValidateList..........3
' xlValidateDate..........4
' xlValidateTime..........5
' xlValidateTextLength....6
' xlValidateCustom........7
Select Case DVType
Case 0:
DVTypeDesc = "Input Only"
Case 1:
DVTypeDesc = "Whole Number"
Case 2:
DVTypeDesc = "Decimal"
Case 3:
DVTypeDesc = "List"
Case 4:
DVTypeDesc = "Date"
Case 5:
DVTypeDesc = "Time"
Case 6:
DVTypeDesc = "Text Length"
Case 7:
DVTypeDesc = "Custom"
End Select
.Offset(RowOffset:=Ctr, ColumnOffset:=1).Value = DVTypeDesc
.Offset(RowOffset:=Ctr, ColumnOffset:=2).Value = "'" & cCell.Validation.Formula1
.Offset(RowOffset:=Ctr, ColumnOffset:=3).Value = "'" & cCell.Validation.Formula2
Ctr = Ctr + 1
Next cCell
wksNew.UsedRange.Columns.AutoFit
End With
errTrap:
If Err.Number <> 0 Then
MsgBox "Could not complete operation"
End If
End Sub