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

Hi again,

why doesn't work this:

If IsError(.Range("1").SpecialCells(xlCellTypeBlanks) .Cells
(1)) = False Then

When I run the macro I get the error note "no cells were
found. run-time error 1004" because the range is filled up
and the macro stops instead of running the else command

Thanks a lot for your help and best regards

Markus
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default IsError Function

Try

If IsError(.Range("1:1").SpecialCells(xlCellTypeBlank s).Cells
(1)) = False Then


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Markus Scheible" wrote in message
...
Hi again,

why doesn't work this:

If IsError(.Range("1").SpecialCells(xlCellTypeBlanks) .Cells
(1)) = False Then

When I run the macro I get the error note "no cells were
found. run-time error 1004" because the range is filled up
and the macro stops instead of running the else command

Thanks a lot for your help and best regards

Markus



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default IsError Function

Hi Bob,


If IsError(.Range("rng:rng").SpecialCells

(xlCellTypeBlanks).Cells
(1)) = False Then


that doesn't work either... same error: "no cells were
found" - the point is: I know that no cells were found -
therefor I used the if command... the thing is that excel
seems to not accept this error within the iferror
function...

Best regards,

Markus
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default IsError Function

I think the error is being generated before the IsError kicks in.

Try a different tack

Set myRng = Nothing
On Error Resume Next
Set myRng = (.Range("rng:rng").SpecialCells(xlCellTypeBlanks). Cells(1))
On Error Goto 0
If myRng Is Nothing Then
... this is the False path
End If
--

HTH

RP
(remove nothere from the email address if mailing direct)


"Markus Scheible" wrote in message
...
Hi Bob,


If IsError(.Range("rng:rng").SpecialCells

(xlCellTypeBlanks).Cells
(1)) = False Then


that doesn't work either... same error: "no cells were
found" - the point is: I know that no cells were found -
therefor I used the if command... the thing is that excel
seems to not accept this error within the iferror
function...

Best regards,

Markus



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default IsError Function

Hi Bob,


I think the error is being generated before the IsError

kicks in.


Could be, but the Debugger stops at that line, so that I
could not imagine how the error would have been generated
before... plus: that line is the first time in the whole
macro that I use the specialcells(xlcelltypeblanks)
command so I doubt that excel produces the error before...



Try a different tack

Set myRng = Nothing
On Error Resume Next
Set myRng = (.Range("rng:rng").SpecialCells

(xlCellTypeBlanks).Cells(1))
On Error Goto 0
If myRng Is Nothing Then
... this is the False path
End If
--


I did that, and it worked... :o)

Nevertheless, thanks for the help.

Best regards,

Markus


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default IsError Function


"Markus Scheible" wrote in message
...
Could be, but the Debugger stops at that line, so that I
could not imagine how the error would have been generated
before... plus: that line is the first time in the whole
macro that I use the specialcells(xlcelltypeblanks)
command so I doubt that excel produces the error before...

Understood, I meant that parsing that statement executed the range setting
part and fell over there before the IsError got its results. Which is why I
went the way I suggested.


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default IsError Function

Iserror only responds to Excel style errors such as

? cverr(xlErrNa)
Error 2042
? iserror(cvErr(xlErrNA))
True

this is equivalent to
#N/A

on the worksheet.

Special Cells Raises a Trappable error when it fails. This is handled as
Bob has shown you.

--
Regards,
Tom Ogilvy



"Markus Scheible" wrote in message
...
Hi Bob,


If IsError(.Range("rng:rng").SpecialCells

(xlCellTypeBlanks).Cells
(1)) = False Then


that doesn't work either... same error: "no cells were
found" - the point is: I know that no cells were found -
therefor I used the if command... the thing is that excel
seems to not accept this error within the iferror
function...

Best regards,

Markus



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default IsError Function

Hi Tom,

Special Cells Raises a Trappable error when it fails.

This is handled as
Bob has shown you.


thanks for the info.

Best regards

Markus
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default IsError Function

Note that the way you have written the statement, what you as asking for is
whether the VALUE in the first blank cell is an error value -- which of course
is nonsense: if the cell is blank, it can't contain an error value.

When there are no blank cells, you get a run-time error at the point where VBA
is trying to create a temporary range variable that contains no cells.

If what you want to know is whether there ARE any blank cells, and do that
without raising an error, you could use

If Application.COUNTBLANK(Rng) 0 Then

or

If Application.COUNTA(Rng) < Rng.Cells.Count Then

or, with error trapping

On Error Resume Next
Set Rng2 = Rng.SpecialCells(xlCellTypeBlanks)
If Err.Number < 0 Then 'no blanks

On Wed, 26 Jan 2005 02:46:43 -0800, "Markus Scheible"
wrote:

Hi again,

why doesn't work this:

If IsError(.Range("1").SpecialCells(xlCellTypeBlanks) .Cells
(1)) = False Then

When I run the macro I get the error note "no cells were
found. run-time error 1004" because the range is filled up
and the macro stops instead of running the else command

Thanks a lot for your help and best regards

Markus


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
ISERROR function Gotroots Excel Worksheet Functions 2 January 6th 10 01:21 PM
Excel ISERROR function MarkD Excel Worksheet Functions 1 December 12th 05 10:13 PM
how do I write a vlookup function within an iserror function so t. JBLeeds Excel Worksheet Functions 2 March 16th 05 10:30 AM
Can I use ISERROR with VLOOKUP function? Alex Hatzisavas[_2_] Excel Programming 1 September 22nd 04 06:57 PM
Can I use ISERROR with VLOOKUP function? Frank Kabel Excel Programming 0 September 20th 04 04:36 PM


All times are GMT +1. The time now is 11:37 AM.

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

About Us

"It's about Microsoft Excel"