Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Data validation question
I hve a lot of validation on a sheet, I know that you can highlight invalid
cells by using Tools | Auditing | Show Auditing Toolbar | Circle Invalid Data This is very useful but I wondered if it was possible to count the number of invalid cells and display in a message box as my sheet may contain several hundred rows. Thanks in advace. Gareth |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Data validation question
The following macro counts the data validation cells with errors:
Sub CountDVErrors() Dim rngDV As Range Dim c As Range Dim countDV As Long Dim ws As Worksheet Set ws = ActiveSheet On Error GoTo errHandler Set rngDV = ws.Cells.SpecialCells(xlCellTypeAllValidation) On Error GoTo 0 countDV = 0 For Each c In rngDV If Not c.Validation.Value Then countDV = countDV + 1 End If Next MsgBox "There are " & countDV & " DV cells with errors" Exit Sub errHandler: MsgBox "No cells with data validation on the active sheet." End Sub Gareth wrote: I hve a lot of validation on a sheet, I know that you can highlight invalid cells by using Tools | Auditing | Show Auditing Toolbar | Circle Invalid Data This is very useful but I wondered if it was possible to count the number of invalid cells and display in a message box as my sheet may contain several hundred rows. Thanks in advace. Gareth -- Debra Dalgleish Excel FAQ, Tips & Book List http://www.contextures.com/tiptech.html |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Data validation question
How about:
Option Explicit Sub testme01() Dim myCount As Long Dim myCell As Range Dim myRange As Range Set myRange = Nothing On Error Resume Next Set myRange = ActiveSheet.Cells.SpecialCells(xlCellTypeAllValida tion) On Error GoTo 0 If myRange Is Nothing Then MsgBox "no Validation on this sheet" Exit Sub End If 'ActiveSheet.CircleInvalid myCount = 0 For Each myCell In myRange.Cells If myCell.Validation.Value = False Then myCount = myCount + 1 End If Next myCell MsgBox "Found invalid: " & myCount & vbLf _ & "From: " & myRange.Cells.Count End Sub Gareth wrote: I hve a lot of validation on a sheet, I know that you can highlight invalid cells by using Tools | Auditing | Show Auditing Toolbar | Circle Invalid Data This is very useful but I wondered if it was possible to count the number of invalid cells and display in a message box as my sheet may contain several hundred rows. Thanks in advace. Gareth -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Data Validation question | Excel Discussion (Misc queries) | |||
Data Validation question | Excel Discussion (Misc queries) | |||
Data Validation Question | Excel Discussion (Misc queries) | |||
Data Validation Question? | Excel Worksheet Functions | |||
Another Data Validation question | Excel Discussion (Misc queries) |