Home |
Search |
Today's Posts |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
error 13 type mismatch input box | Excel Discussion (Misc queries) | |||
number input error | Excel Discussion (Misc queries) | |||
Code error with input box | Excel Programming | |||
Formula input error help | Excel Discussion (Misc queries) | |||
Input Box error when scrolling | Excel Programming |