Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 213
Default To Check Errors for a range of cells

Hi,

I want to write a code to check whether errors exist in column E. I use the
following code:

Dim r as Interger
r=9
r=r+1
If iserror(cells(r,5)) then
Msgbox "Please fix error"
else


Thanks. Please help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default To Check Errors for a range of cells

Sub FindErrors()
Dim myCell As Range
On Error GoTo NoErrors
For Each myCell In Range("E:E").SpecialCells(xlCellTypeFormulas, 16)
MsgBox "Cell " & myCell.Address & " has an error, so please fix it!"
Next myCell
Exit Sub
NoErrors:
MsgBox "No errors were found in column E."
End Sub

HTH,
Bernie
MS Excel MVP


"AccessHelp" wrote in message
...
Hi,

I want to write a code to check whether errors exist in column E. I use the
following code:

Dim r as Interger
r=9
r=r+1
If iserror(cells(r,5)) then
Msgbox "Please fix error"
else


Thanks. Please help.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 213
Default To Check Errors for a range of cells

Hi Bernie,

Thanks for your help. I need a different code. This code would not work
for me. Please help.

I am only testing the cells from E9 to E83. Those cells are password
protected and the values in those cells are looking at the cells from D9 to
d83 using vlookup. For example, if a user types in a wrong data in D9, E9
would return #N/A. I want to test E9 to E83 to make sure that we don't have
any #N/A.

Also I need it in IF statement. In my code, I am testing on several things
using IFs (so if that is correct, go on to another one.).

Thanks.

"Bernie Deitrick" wrote:

Sub FindErrors()
Dim myCell As Range
On Error GoTo NoErrors
For Each myCell In Range("E:E").SpecialCells(xlCellTypeFormulas, 16)
MsgBox "Cell " & myCell.Address & " has an error, so please fix it!"
Next myCell
Exit Sub
NoErrors:
MsgBox "No errors were found in column E."
End Sub

HTH,
Bernie
MS Excel MVP


"AccessHelp" wrote in message
...
Hi,

I want to write a code to check whether errors exist in column E. I use the
following code:

Dim r as Interger
r=9
r=r+1
If iserror(cells(r,5)) then
Msgbox "Please fix error"
else


Thanks. Please help.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default To Check Errors for a range of cells

Actually, it would work for you, but have it your way:

Sub FindErrors()
Dim myCell As Range
For Each myCell In Range("E9:E83")
If IsError(myCell.Value) Then
MsgBox "Cell " & myCell.Address & " has an error, so please fix it!"
' Other stuff here
End If
Next myCell
End Sub

HTH,
Bernie
MS Excel MVP


"AccessHelp" wrote in message
...
Hi Bernie,

Thanks for your help. I need a different code. This code would not work
for me. Please help.

I am only testing the cells from E9 to E83. Those cells are password
protected and the values in those cells are looking at the cells from D9 to
d83 using vlookup. For example, if a user types in a wrong data in D9, E9
would return #N/A. I want to test E9 to E83 to make sure that we don't have
any #N/A.

Also I need it in IF statement. In my code, I am testing on several things
using IFs (so if that is correct, go on to another one.).

Thanks.

"Bernie Deitrick" wrote:

Sub FindErrors()
Dim myCell As Range
On Error GoTo NoErrors
For Each myCell In Range("E:E").SpecialCells(xlCellTypeFormulas, 16)
MsgBox "Cell " & myCell.Address & " has an error, so please fix it!"
Next myCell
Exit Sub
NoErrors:
MsgBox "No errors were found in column E."
End Sub

HTH,
Bernie
MS Excel MVP


"AccessHelp" wrote in message
...
Hi,

I want to write a code to check whether errors exist in column E. I use the
following code:

Dim r as Interger
r=9
r=r+1
If iserror(cells(r,5)) then
Msgbox "Please fix error"
else


Thanks. Please help.






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 213
Default To Check Errors for a range of cells

Hi Bernie,

Thanks again for your help. I still need help. Please see below of a
portion of my code.

If Not IsDate(Range("B8")) Then
MsgBox "Please enter a week ending date in cell B8."
ElseIf IsError(Range("K6")) Then
MsgBox "Please enter your employee # in cell C8."
ElseIf (That is where I want to check the values in E9:E83)
Msgbox (if there is an error, prompt message and skip the
code all the way to "ActiveWorkbook.Save". If no error, go through the rest
of code until "ActiveWorkbook.Save".)
Else
(Do the rest of code)
End If
ActiveWorkbook.Save
End Sub

Thanks again.


"Bernie Deitrick" wrote:

Actually, it would work for you, but have it your way:

Sub FindErrors()
Dim myCell As Range
For Each myCell In Range("E9:E83")
If IsError(myCell.Value) Then
MsgBox "Cell " & myCell.Address & " has an error, so please fix it!"
' Other stuff here
End If
Next myCell
End Sub

HTH,
Bernie
MS Excel MVP


"AccessHelp" wrote in message
...
Hi Bernie,

Thanks for your help. I need a different code. This code would not work
for me. Please help.

I am only testing the cells from E9 to E83. Those cells are password
protected and the values in those cells are looking at the cells from D9 to
d83 using vlookup. For example, if a user types in a wrong data in D9, E9
would return #N/A. I want to test E9 to E83 to make sure that we don't have
any #N/A.

Also I need it in IF statement. In my code, I am testing on several things
using IFs (so if that is correct, go on to another one.).

Thanks.

"Bernie Deitrick" wrote:

Sub FindErrors()
Dim myCell As Range
On Error GoTo NoErrors
For Each myCell In Range("E:E").SpecialCells(xlCellTypeFormulas, 16)
MsgBox "Cell " & myCell.Address & " has an error, so please fix it!"
Next myCell
Exit Sub
NoErrors:
MsgBox "No errors were found in column E."
End Sub

HTH,
Bernie
MS Excel MVP


"AccessHelp" wrote in message
...
Hi,

I want to write a code to check whether errors exist in column E. I use the
following code:

Dim r as Interger
r=9
r=r+1
If iserror(cells(r,5)) then
Msgbox "Please fix error"
else


Thanks. Please help.








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default To Check Errors for a range of cells

Try something like the code below.

HTH,
Bernie
MS Excel MVP

Sub TryNow()
Dim NeedInput As Boolean
Dim myCell As Range

NeedInput = Not IsDate(Range("B8").Value)

While NeedInput
Range("B8").Value = InputBox("What is the week ending date for cell B8?")
NeedInput = Not IsDate(Range("B8").Value)
Wend

NeedInput = IsError(Range("K6").Value)

While NeedInput
Range("C8").Value = InputBox("What is your employee # for cell C8.")
NeedInput = IsError(Range("K6").Value)
Wend

On Error GoTo NoErrors
Set myCell = Range("E9:E83").SpecialCells(xlCellTypeFormulas, 16)
MsgBox "There are errors in range E9:E83"
GoTo SaveCode:

NoErrors:

MsgBox "I'm going to do the rest of the code now"
'(Do the rest of code)
'Rest of code here

SaveCode:

ActiveWorkbook.Save
End Sub


"AccessHelp" wrote in message
...
Hi Bernie,

Thanks again for your help. I still need help. Please see below of a
portion of my code.

If Not IsDate(Range("B8")) Then
MsgBox "Please enter a week ending date in cell B8."
ElseIf IsError(Range("K6")) Then
MsgBox "Please enter your employee # in cell C8."
ElseIf (That is where I want to check the values in E9:E83)
Msgbox (if there is an error, prompt message and skip the
code all the way to "ActiveWorkbook.Save". If no error, go through the rest
of code until "ActiveWorkbook.Save".)
Else
(Do the rest of code)
End If
ActiveWorkbook.Save
End Sub

Thanks again.


"Bernie Deitrick" wrote:

Actually, it would work for you, but have it your way:

Sub FindErrors()
Dim myCell As Range
For Each myCell In Range("E9:E83")
If IsError(myCell.Value) Then
MsgBox "Cell " & myCell.Address & " has an error, so please fix it!"
' Other stuff here
End If
Next myCell
End Sub

HTH,
Bernie
MS Excel MVP


"AccessHelp" wrote in message
...
Hi Bernie,

Thanks for your help. I need a different code. This code would not work
for me. Please help.

I am only testing the cells from E9 to E83. Those cells are password
protected and the values in those cells are looking at the cells from D9 to
d83 using vlookup. For example, if a user types in a wrong data in D9, E9
would return #N/A. I want to test E9 to E83 to make sure that we don't have
any #N/A.

Also I need it in IF statement. In my code, I am testing on several things
using IFs (so if that is correct, go on to another one.).

Thanks.

"Bernie Deitrick" wrote:

Sub FindErrors()
Dim myCell As Range
On Error GoTo NoErrors
For Each myCell In Range("E:E").SpecialCells(xlCellTypeFormulas, 16)
MsgBox "Cell " & myCell.Address & " has an error, so please fix it!"
Next myCell
Exit Sub
NoErrors:
MsgBox "No errors were found in column E."
End Sub

HTH,
Bernie
MS Excel MVP


"AccessHelp" wrote in message
...
Hi,

I want to write a code to check whether errors exist in column E. I use the
following code:

Dim r as Interger
r=9
r=r+1
If iserror(cells(r,5)) then
Msgbox "Please fix error"
else


Thanks. Please help.








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
How to check if the values in a range of cells are greater than 0 DP Excel Worksheet Functions 3 March 19th 10 01:31 PM
Check text in range of cells tommcbrny Excel Discussion (Misc queries) 2 September 11th 09 05:11 PM
Check for errors Pat Excel Worksheet Functions 3 February 24th 05 06:08 PM
Check for errors Pat Excel Worksheet Functions 9 January 31st 05 12:19 AM
How to check cells in a range for a value BCS Excel Programming 1 October 3rd 03 09:20 PM


All times are GMT +1. The time now is 10:17 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"