How To Find Which Cells contain data validation

thewiseguy

Well-known Member
Joined
May 23, 2005
Messages
1,014
Office Version
  1. 365
Platform
  1. Windows
Hi all - I am trying to run through the many tables I have created in my workbook and see which ones are no longer being used. Is there a way to do this?

Thanks in advance!
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Do you mean something like this?

I think this is the answer to the title, but I doubt that this is the answer to the problem of the question itself?

This selects all cells in the active worksheet that have a Data Validation Rule.
When they are selected, you can, for example, define a fill color for them.

VBA Code:
Sub TS_FindDataValidations()
Dim RangeToTest As Range: Set RangeToTest = ActiveSheet.UsedRange
Dim iC As Variant, DataValidationType As Variant
Dim CellsWithValidation As Range

For Each iC In RangeToTest.Cells
    DataValidationType = Null                               ' Clearing the Datavalidation type for next cell
        On Error Resume Next                                ' If no validation in cell then error, so skip errors
            DataValidationType = iC.Validation.Type         ' Read the possible Data Validation type
        On Error GoTo 0                                     ' Back to normal error handling.
       
        If Not IsNull(DataValidationType) Then              ' Checking if the Datavalidation type has been read from the cell.
            If CellsWithValidation Is Nothing Then          ' Check if the CellsWithValidation area is already created
                Set CellsWithValidation = iC                ' Will be created if still empty
            Else
                Set CellsWithValidation = Union(CellsWithValidation, iC) ' Add a Cell with a Datavalidation Rule to the CellsWithValidation range.
            End If
        End If
Next iC

CellsWithValidation.Select ' Selecting all cells containing Data Validation rules.
End Sub

My apologies for any quirks, English is not my native language. "So I blame Google translate for all my goofs." :devilish:
 
Upvote 0
Code:
ActiveSheet.UsedRange.SpecialCells(xlCellTypeAllValidation).Select

should be sufficient?
 
Upvote 0

Forum statistics

Threads
1,221,851
Messages
6,162,429
Members
451,765
Latest member
craigvan888

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top