Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default specialcells and error question

I have the following code, where I want to set rnge to all the cells in
column two that have values in them.

Dim rnge as Range
On Error GoTo nothingIncol2:
Set rnge =
Worksheets("SaveLoad").Range("B:B").SpecialCells(x lCellTypeConstants)
On Error GoTo 0

However, if there is nothing in the B column, it returns a Run-time
error: "No Cells where found".

Shouldn't the error GoTo catch this?

Thanks,

-Abe

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default specialcells and error question

Yes it should. Try removing the colon in the on error goto statement. Just
use

On Error GoTo nothingIncol2
' specialcells code.
On Error goto 0


Exit sub
NothingIncol2:
msgbox "None found
End sub

--
Regards,
Tom Ogilvy

"Abe" wrote:

I have the following code, where I want to set rnge to all the cells in
column two that have values in them.

Dim rnge as Range
On Error GoTo nothingIncol2:
Set rnge =
Worksheets("SaveLoad").Range("B:B").SpecialCells(x lCellTypeConstants)
On Error GoTo 0

However, if there is nothing in the B column, it returns a Run-time
error: "No Cells where found".

Shouldn't the error GoTo catch this?

Thanks,

-Abe


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default specialcells and error question

I removed the colon, but it still gives me an error.

Anything else? Maybe a different way to check for empty cells?

Thanks again Tom,

-Abe

Tom Ogilvy wrote:
Yes it should. Try removing the colon in the on error goto statement. Just
use

On Error GoTo nothingIncol2
' specialcells code.
On Error goto 0


Exit sub
NothingIncol2:
msgbox "None found
End sub

--
Regards,
Tom Ogilvy

"Abe" wrote:

I have the following code, where I want to set rnge to all the cells in
column two that have values in them.

Dim rnge as Range
On Error GoTo nothingIncol2:
Set rnge =
Worksheets("SaveLoad").Range("B:B").SpecialCells(x lCellTypeConstants)
On Error GoTo 0

However, if there is nothing in the B column, it returns a Run-time
error: "No Cells where found".

Shouldn't the error GoTo catch this?

Thanks,

-Abe



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default specialcells and error question

If you just want to count

msgbox Application.CountBlank(Activesheet.usedrange)

But I have never had problems with the construct you show. So I suggest you
go into the VBE and then tools=Options and in the general tab, make sure you
have

break on unhandled errors

select rather than break on all errors.
--
Regards,
Tom Ogilvy



"Abe" wrote:

I removed the colon, but it still gives me an error.

Anything else? Maybe a different way to check for empty cells?

Thanks again Tom,

-Abe

Tom Ogilvy wrote:
Yes it should. Try removing the colon in the on error goto statement. Just
use

On Error GoTo nothingIncol2
' specialcells code.
On Error goto 0


Exit sub
NothingIncol2:
msgbox "None found
End sub

--
Regards,
Tom Ogilvy

"Abe" wrote:

I have the following code, where I want to set rnge to all the cells in
column two that have values in them.

Dim rnge as Range
On Error GoTo nothingIncol2:
Set rnge =
Worksheets("SaveLoad").Range("B:B").SpecialCells(x lCellTypeConstants)
On Error GoTo 0

However, if there is nothing in the B column, it returns a Run-time
error: "No Cells where found".

Shouldn't the error GoTo catch this?

Thanks,

-Abe




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
specialcells(xlLastCell) and method global range error [email protected] Excel Programming 0 July 25th 06 09:51 PM
SpecialCells mike Excel Programming 4 June 8th 06 01:50 AM
SpecialCells Method Question Ken Johnson Excel Programming 11 November 5th 05 02:07 PM
VBA ON ERROR does not work with SPECIALCELLS Felix Excel Discussion (Misc queries) 2 April 14th 05 10:43 PM
Drillthrough MDX ERROR(Error.Number:-21467259) ?(urgent question) Microlong Excel Programming 2 March 4th 05 01:55 AM


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

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"