ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   selecting the first row after a filtered range (https://www.excelbanter.com/excel-programming/368090-selecting-first-row-after-filtered-range.html)

Farooq Sheri

selecting the first row after a filtered range
 
I have a worksheet with information for about 18 nodes. I am able to locate
the data for a particular node and by using AutoFilter I can filter out the
specific row which I require (always a single row). I want to copy this row
to another sheet. xlCellTypeVisible does not work because there is visible
data for other nodes.

Thanks for your help.
Farooq

Norman Jones

selecting the first row after a filtered range
 
Hi Farooq,

Try something like:

'=============
Public Sub Tester()
Dim rng As Range
Dim rng2 As Range

Set rng = ActiveSheet.AutoFilter.Range
Set rng = rng.Offset(1).Resize(rng.Rows.Count - 1)

On Error Resume Next
Set rng2 = rng.SpecialCells(xlCellTypeVisible)
On Error Resume Next

If Not rng2 Is Nothing Then
rng2.Copy Destination:=Sheets(1).Range("A1")
End If
End Sub
'<<=============


---
Regards,
Norman


"Farooq Sheri" wrote in message
...
I have a worksheet with information for about 18 nodes. I am able to locate
the data for a particular node and by using AutoFilter I can filter out
the
specific row which I require (always a single row). I want to copy this
row
to another sheet. xlCellTypeVisible does not work because there is visible
data for other nodes.

Thanks for your help.
Farooq




Farooq Sheri

selecting the first row after a filtered range
 
Thank you for pointing out the way. I used the following line in my code and
it worked

Set rng = rng.Offset(1).Resize(rng.Rows.Count - 1)



"Norman Jones" wrote:

Hi Farooq,

Try something like:

'=============
Public Sub Tester()
Dim rng As Range
Dim rng2 As Range

Set rng = ActiveSheet.AutoFilter.Range
Set rng = rng.Offset(1).Resize(rng.Rows.Count - 1)

On Error Resume Next
Set rng2 = rng.SpecialCells(xlCellTypeVisible)
On Error Resume Next

If Not rng2 Is Nothing Then
rng2.Copy Destination:=Sheets(1).Range("A1")
End If
End Sub
'<<=============


---
Regards,
Norman


"Farooq Sheri" wrote in message
...
I have a worksheet with information for about 18 nodes. I am able to locate
the data for a particular node and by using AutoFilter I can filter out
the
specific row which I require (always a single row). I want to copy this
row
to another sheet. xlCellTypeVisible does not work because there is visible
data for other nodes.

Thanks for your help.
Farooq






All times are GMT +1. The time now is 09:45 AM.

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