View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Susan Susan is offline
external usenet poster
 
Posts: 1,117
Default VBA validation & error reporting

as far as i can see, you're exiting the "do" without "doing" anything.

Do While Application.CountIf(Range(MyRng(j)),Range(MyCell(i )).Value)=0
If <the cell has an error - would take me too long to
figure out how to write it exactly then
MsgBox "Check the value in cell" & MyCell(i)
Exit sub
End If
Next j
Next i
Loop
xxxxxxxxxxxxxxx
susan


Kragelund wrote:
Public Sub Data_Analysis_test()
Dim MyCell, MyRng, i As Integer, j As Integer, flg As Boolean, Name As Range
MyCell = Array("B1", "C1")
MyRng = Array("D7:G23", "D27:G41", "d45:G72", "i45:j70")
For i = 0 To UBound(MyCell)
For j = 0 To UBound(MyRng)
Do While Application.CountIf(Range(MyRng(j)), Range(MyCell(i)).Value) = 0
Exit Do
MsgBox "Check the value in cell " & MyCell(i)
Next j
Next i
Loop
End Sub