Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Excel03 - empty cells and SpecialCells ( xlVisible )

Hi,

I have a sheet of data that has the Autofilter applied and I want to get a
column of filtered data and transfer it to another sheet. The code below
works most of the time but when I try to grab a range of data and the
filtered sheet does not show any data (because I have filtered using a
criteria that does not match any data in the column under consideration - I
can't change this unfortunately) I get an Error 1004 "Cells were not found"
and the routine crashes out.

' Code applies autofiltering based on user entered criteria before this
section

' Copy Task Numbers
Set rng1 = Worksheets("FEPivot").Range("K6:K500")
Set rng1 = rng1.SpecialCells(xlVisible)
rng1.Copy Destination:=Worksheets("StatusSummary").Range("A2 9")

' Code continues...


What I want to do is if the range selected does not contain any cells with
data in just have the code step over these lines onto the next set of
scripts. Is the an approach that will allow me to do this?

Regards

Chris


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Excel03 - empty cells and SpecialCells ( xlVisible )

Dim rng1 as Range, rng2 as Range
' Copy Task Numbers
Set rng1 = Worksheets("FEPivot").Range("K6:K500")
Set rng2 = nothing
On Error Resume Next
Set rng2 = rng1.SpecialCells(xlVisible)
On Error goto 0
if not rng2 is nothing then
rng2.Copy Destination:=Worksheets("StatusSummary").Range("A2 9")
end if
--
Regards,
Tom Ogilvy


"Chris Paterson" wrote in message
...
Hi,

I have a sheet of data that has the Autofilter applied and I want to get a
column of filtered data and transfer it to another sheet. The code below
works most of the time but when I try to grab a range of data and the
filtered sheet does not show any data (because I have filtered using a
criteria that does not match any data in the column under consideration -

I
can't change this unfortunately) I get an Error 1004 "Cells were not

found"
and the routine crashes out.

' Code applies autofiltering based on user entered criteria before

this
section

' Copy Task Numbers
Set rng1 = Worksheets("FEPivot").Range("K6:K500")
Set rng1 = rng1.SpecialCells(xlVisible)
rng1.Copy Destination:=Worksheets("StatusSummary").Range("A2 9")

' Code continues...


What I want to do is if the range selected does not contain any cells with
data in just have the code step over these lines onto the next set of
scripts. Is the an approach that will allow me to do this?

Regards

Chris




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Excel03 - empty cells and SpecialCells ( xlVisible )

Many thanks Tom, crisis over...

"Tom Ogilvy" wrote in message
...
Dim rng1 as Range, rng2 as Range
' Copy Task Numbers
Set rng1 = Worksheets("FEPivot").Range("K6:K500")
Set rng2 = nothing
On Error Resume Next
Set rng2 = rng1.SpecialCells(xlVisible)
On Error goto 0
if not rng2 is nothing then
rng2.Copy Destination:=Worksheets("StatusSummary").Range("A2 9")
end if
--
Regards,
Tom Ogilvy


"Chris Paterson" wrote in message
...
Hi,

I have a sheet of data that has the Autofilter applied and I want to get
a
column of filtered data and transfer it to another sheet. The code below
works most of the time but when I try to grab a range of data and the
filtered sheet does not show any data (because I have filtered using a
criteria that does not match any data in the column under consideration -

I
can't change this unfortunately) I get an Error 1004 "Cells were not

found"
and the routine crashes out.

' Code applies autofiltering based on user entered criteria before

this
section

' Copy Task Numbers
Set rng1 = Worksheets("FEPivot").Range("K6:K500")
Set rng1 = rng1.SpecialCells(xlVisible)
rng1.Copy Destination:=Worksheets("StatusSummary").Range("A2 9")

' Code continues...


What I want to do is if the range selected does not contain any cells
with
data in just have the code step over these lines onto the next set of
scripts. Is the an approach that will allow me to do this?

Regards

Chris






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
Excel - Autom. Filter "Empty / Non Empty cells" should come first Rom Excel Discussion (Misc queries) 0 August 10th 05 04:32 PM
macro to colour empty cells (cells not recognized as empty) Gerben Excel Programming 5 June 30th 05 03:29 PM
.Cells.SpecialCells(xlLastCell) Simon Shaw Excel Programming 8 May 5th 05 11:46 PM
How select/define cells with FIND method (maybe together with SpecialCells) Marie J-son[_5_] Excel Programming 2 December 14th 04 03:49 PM
Can blank cells created using empty Double-Quotes not be empty?? JohnI in Brisbane Excel Programming 6 September 7th 03 11:22 PM


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