ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Error, when autofilter does not return visible rows (https://www.excelbanter.com/excel-programming/388562-error-when-autofilter-does-not-return-visible-rows.html)

axel

Error, when autofilter does not return visible rows
 
Hi,
I have following problem: I'm using Autofilter to select data from a sheet
and transfer it a different sheet. Unfortunally, when no data is found by
autofilter I get following error message on 3rd line of the following code:
"Run time error 1004 - no cells were found".
Does anybody have an idea how to avoid this error?

Range(Cells(2, 1), Cells(No_Rows_Source, 1)).Select
Set Rng = Selection
Set RngVis = Rng.SpecialCells(xlVisible)
For Each Cll In RangVis
.....
Next

Kind regards, AXEL

Dave Peterson

Error, when autofilter does not return visible rows
 
I like to count the number of visible rows.

if activesheet.autofilter.range _
.columns(1).cells.specialcells(xlcelltypevisible) = 1 then
'only headers, no data
else
'there's something there, do the stuff
end if
end with



Axel wrote:

Hi,
I have following problem: I'm using Autofilter to select data from a sheet
and transfer it a different sheet. Unfortunally, when no data is found by
autofilter I get following error message on 3rd line of the following code:
"Run time error 1004 - no cells were found".
Does anybody have an idea how to avoid this error?

Range(Cells(2, 1), Cells(No_Rows_Source, 1)).Select
Set Rng = Selection
Set RngVis = Rng.SpecialCells(xlVisible)
For Each Cll In RangVis
.....
Next

Kind regards, AXEL


--

Dave Peterson

axel

Error, when autofilter does not return visible rows
 
Thanks, this helped ...

"Dave Peterson" wrote:

I like to count the number of visible rows.

if activesheet.autofilter.range _
.columns(1).cells.specialcells(xlcelltypevisible) = 1 then
'only headers, no data
else
'there's something there, do the stuff
end if
end with



Axel wrote:

Hi,
I have following problem: I'm using Autofilter to select data from a sheet
and transfer it a different sheet. Unfortunally, when no data is found by
autofilter I get following error message on 3rd line of the following code:
"Run time error 1004 - no cells were found".
Does anybody have an idea how to avoid this error?

Range(Cells(2, 1), Cells(No_Rows_Source, 1)).Select
Set Rng = Selection
Set RngVis = Rng.SpecialCells(xlVisible)
For Each Cll In RangVis
.....
Next

Kind regards, AXEL


--

Dave Peterson



All times are GMT +1. The time now is 05:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com