View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Filtered data selection using vba

After closely reading your postings, it sounds like you are not properly
applying the filter (a filter can filter the entire sheet). If you have
blank rows in your data, you need to select all your data and then apply the
filter. If You still want to copy filled rows beyond the autofilter range,
you can do:

Dim rng as Range, rng1 as range
set rng = Activesheet.Autofilter.range.Columns(1).cells
set rng = rng.offset(1,0)
set rng1 = rng(rng.count)
set rng = Cells(rows.count,1).End(xlup)
range(rng1,rng).EntireRow.copy Destination:= _
Worksheets("Sheet2").Range("A1")

--
Regards,
Tom Ogilvy




"sudhendra" wrote in message
...
I tried with this code below :-

The problem is if some of my rows are invisible like if
the data rows filtered are Like 1, 3,
7,12,111,112,113,114...897
I am unable to get the fourth and beyond ie., 111th row
to 897th row for selection.

Sub Increment1()
Dim rng As Range, rng1 As Range
Dim icol As Long
icol = ActiveCell.Column
Set rng = ActiveSheet.AutoFilter.Range
Set rng = Intersect(rng, Columns(icol))
Set rng = Range(ActiveCell.Offset(1, 0), rng(rng.Count))
On Error Resume Next
Set rng1 = rng.SpecialCells(xlVisible)
On Error GoTo 0
If Not rng1 Is Nothing Then
rng1(1).Select
End If
End Sub


-----Original Message-----
When filtered, some rows are hidden and some visible.

Do you want to select the 6th visible row and beyond to

copy.

What kind of filter did you apply

Dim rng as Range, rng1 as range, cell as range
Dim i as long
set rng = Activesheet.Autofilter.range.Columns(1)
set rng = rng.offset(1,0).Resize(rng.rows.count-1)
set rng1 = rng(rng.count)
set rng = rng.Specialcells(xlvisible)
i = 0
for each cell in rng
i = i + 1
if i = 6 then
range(cell,rng1).EntireRow.copy Destination:= _
Worksheets("Sheet2").Range("A1")
exit for
end if
Next


--
Regards,
Tom Ogilvy

"sudhendra" wrote

in message
...
Hi

I have filtered some data (they are filted from

differnet
rows)

I want to skip the first 5 rows of this filtered data

and
select the remaining data (as i cannot filter

anyfurther)
copy it into another new sheet.

Can any one help please thanks inadvance



.