LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default error in input

Hi Pierre,

Try:
'================
Sub But_test_click()
Dim rng As Range
Dim RngA As Range, RngB As Range
Dim RngBig As Range
Dim rCell As Range
Dim rw As Range
Dim WB As Workbook
Dim SH As Worksheet
Dim msg As String

Set WB = ActiveWorkbook
Set SH = WB.Sheets("Deelnemers")
Set rng = Columns("A:X")

On Error Resume Next
Set RngA = rng.SpecialCells(xlCellTypeConstants, xlErrors)
Set RngB = rng.SpecialCells(xlCellTypeFormulas, xlErrors)
On Error GoTo 0

If Not RngA Is Nothing Then Set RngBig = RngA

If Not RngB Is Nothing Then
If Not RngBig Is Nothing Then
Set RngBig = Union(RngB, RngBig)
Else
Set RngBig = RngB
End If
End If

If Not RngBig Is Nothing Then
For Each rCell In RngBig.Rows
Set RngBig = Union(RngBig, rCell.EntireRow)
Next rCell
msg = "Errors found in rows:"
For Each rw In RngBig.Rows
msg = msg & vbNewLine & rw.Row
Next rw
msg = msg & vbNewLine & _
"Check your input and press the button again please'"
Else
msg = "No errors found"
End If
MsgBox Prompt:=msg, _
Buttons:=vbInformation, _
Title:="ErrorReport"

End Sub
'<<================


Assuming that you have protected the sheet using the UserInterfaceOnly
parameter, it is not necessary to unprotect / reprotect the sheet.

---
Regards,
Norman


"Pierre via OfficeKB.com" <u13950@uwe wrote in message
news:57a4a88217462@uwe...
Hi Norman,

thanks for the UserInterfaceOnly solution !

In my application the user can fill in only 4 columns (B,C,E,and F)
Only C,E and F can cause possible error (because these are colums where
the
user has to input a date, salary and a parttime%. The rest of the columns
are
calculations based on the user input.

The code you gave now gives the first error that it encounters.
Is there a code that would give msgbox stating all the rows where errors
occurred?
By the way, i adapted the code to the following:
sub but_test click()
Dim rng1 As Range
Dim rng2
Set rng1 = Range("A3:X1000")
On Error Resume Next
Sheets("deelnemers").Unprotect Password:="ekmef1"
Set rng2 = rng1.SpecialCells(xlCellTypeFormulas, xlErrors)
On Error GoTo 0
If Not rng2 Is Nothing Then
'Errors found
MsgBox "your input cause an error in row " & rng2.Row - 2 & _
Chr(13) & Chr(13) & "Check your input and press the button again
please'"
Sheets("deelnemers").Protect Password:="ekmef1"
Exit Sub
End If

Please help me again and thanks,
Pierre



 
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
error 13 type mismatch input box cluckers Excel Discussion (Misc queries) 1 October 28th 09 07:01 PM
number input error Mick Excel Discussion (Misc queries) 2 August 24th 08 11:15 AM
Code error with input box raw Excel Programming 1 October 25th 05 02:55 AM
Formula input error help JV15 Excel Discussion (Misc queries) 1 May 23rd 05 09:45 AM
Input Box error when scrolling jurgenC![_2_] Excel Programming 3 January 16th 04 10:36 PM


All times are GMT +1. The time now is 10:00 PM.

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

About Us

"It's about Microsoft Excel"