Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Validation question Lost Excel Discussion (Misc queries) 1 June 2nd 09 08:39 AM
Data Validation question ozhunter Excel Discussion (Misc queries) 3 December 16th 08 12:25 AM
Data Validation Question Andrew Mackenzie Excel Discussion (Misc queries) 1 January 22nd 07 02:57 PM
Data Validation Question? mastermind Excel Worksheet Functions 2 December 22nd 06 05:26 PM
Another Data Validation question Nigel Excel Discussion (Misc queries) 3 October 14th 05 10:37 PM


All times are GMT +1. The time now is 04:34 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"