Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Error Problem

Hi

Thanks for the help with the last query. I have the
following code which creates an exceptions report by
checking which formulas have errors in them on
sheet "Email".

The problem is if there are no errors in the sheet it
comes up with the message "Run time error 1004, No cells
were found"

I thought that on error resume next would sort this out
but it doenst seem to work - any ideas?

Sub Exceptions_Report()
Dim rng As Range, rng1 As Range, rng2 As Range

Application.ScreenUpdating = False

With Worksheets("Email")
Set rng = .Range(.Cells(1, 1), .Cells(1, 1).End(xlDown))
On Error Resume Next
Set rng1 = rng.Offset(0, 1).Resize(, 2).SpecialCells
(xlFormulas, xlErrors)
On Error GoTo 0
If Not rng1 Is Nothing Then
Set rng2 = Intersect(rng1.EntireRow, .Range("A:C"))
rng2.Copy Destination:=Worksheets
("Exceptions_Report").Range("A8")
End If
End With

Worksheets("Exceptions_Report").Select
Columns("A:A").HorizontalAlignment = xlLeft

With Worksheets("Exceptions_Report").PageSetup
..PrintTitleRows = "$1:$7"
..LeftMargin = Application.InchesToPoints(0.748031496062992)
..RightMargin = Application.InchesToPoints
(0.748031496062992)
..TopMargin = Application.InchesToPoints(0.984251968503937)
..BottomMargin = Application.InchesToPoints
(0.984251968503937)
..HeaderMargin = Application.InchesToPoints
(0.511811023622047)
..FooterMargin = Application.InchesToPoints
(0.511811023622047)
..CenterHorizontally = True
..Orientation = xlPortrait
End With

Application.ScreenUpdating = False
Exceptions.Show


End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default Error Problem

Edgar,

I tried your macro (through the first 'End With' statement) with a sample
pair of worksheets and could not reproduce the problem. Which line of code
is triggering the error message? Can you give us a set of sample data that
produces the error for you?

You should not need the 'On Error' statement. The statement:

Set rng1 = rng.Offset(0, 1).Resize(, 2).SpecialCells _
(xlFormulas, xlErrors)

will not trigger an error if no cells are found. You will just get a range
that equals Nothing. Testing for the range being Nothing, as you do
subsequently in your code is sufficient precaution against the case of no
cells being found.

Shockley


"Edgar" wrote in message
...
Hi

Thanks for the help with the last query. I have the
following code which creates an exceptions report by
checking which formulas have errors in them on
sheet "Email".

The problem is if there are no errors in the sheet it
comes up with the message "Run time error 1004, No cells
were found"

I thought that on error resume next would sort this out
but it doenst seem to work - any ideas?

Sub Exceptions_Report()
Dim rng As Range, rng1 As Range, rng2 As Range

Application.ScreenUpdating = False

With Worksheets("Email")
Set rng = .Range(.Cells(1, 1), .Cells(1, 1).End(xlDown))
On Error Resume Next
Set rng1 = rng.Offset(0, 1).Resize(, 2).SpecialCells
(xlFormulas, xlErrors)
On Error GoTo 0
If Not rng1 Is Nothing Then
Set rng2 = Intersect(rng1.EntireRow, .Range("A:C"))
rng2.Copy Destination:=Worksheets
("Exceptions_Report").Range("A8")
End If
End With

Worksheets("Exceptions_Report").Select
Columns("A:A").HorizontalAlignment = xlLeft

With Worksheets("Exceptions_Report").PageSetup
.PrintTitleRows = "$1:$7"
.LeftMargin = Application.InchesToPoints(0.748031496062992)
.RightMargin = Application.InchesToPoints
(0.748031496062992)
.TopMargin = Application.InchesToPoints(0.984251968503937)
.BottomMargin = Application.InchesToPoints
(0.984251968503937)
.HeaderMargin = Application.InchesToPoints
(0.511811023622047)
.FooterMargin = Application.InchesToPoints
(0.511811023622047)
.CenterHorizontally = True
.Orientation = xlPortrait
End With

Application.ScreenUpdating = False
Exceptions.Show


End Sub



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
Error problem Ayo Excel Discussion (Misc queries) 11 May 20th 09 04:52 PM
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Worksheet Functions 1 May 3rd 08 02:35 PM
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Discussion (Misc queries) 1 May 3rd 08 10:52 AM
Problem with #VALUE/0! error Ted Excel Worksheet Functions 2 November 22nd 05 03:37 PM
Unknown where is the problem on the Runtime error - Automation error wellie Excel Programming 1 July 10th 03 08:12 AM


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