PDA

View Full Version : select the second row of the result of advanced filter.



uktous
02-03-2014, 09:03 AM
Hi,

Could you please write the marco to select the second row of the result of advanced filter?

Thanks

DILIPandey
02-10-2014, 12:42 AM
Hi uktous,

Use below code:-



Sub DILIPandey()
'selecting second row of autofiltered region
Selection.CurrentRegion.Select
'Selection.AutoFilter Field:=2, Criteria1:=">7" ' this is the filter criteria which you can modify
Selection.Range("B2").Select
For i = 1 To 2
chk = ActiveCell.EntireRow.Hidden
While chk = True
ActiveCell.Offset(1, 0).Select
chk = ActiveCell.EntireRow.Hidden
Wend
ActiveCell.Offset(1, 0).Select
Next
ActiveCell.Offset(-1, 0).EntireRow.Select
End Sub



Regards,
DILIPandey

mancubus
02-10-2014, 01:32 AM
hey uktous. ----- i think you want to select the first visible row after header row. ----- (1) does your table have records that meet the advance filter criteria each time you filter? (2) will you advance filter the records manually all the time? (3) and is there a specific reason why you are wanting to select a row.

uktous
02-10-2014, 09:31 AM
hey uktous. ----- i think you want to select the first visible row after header row. ----- (1) does your table have records that meet the advance filter criteria each time you filter? (2) will you advance filter the records manually all the time? (3) and is there a specific reason why you are wanting to select a row.


(1) does your table have records that meet the advance filter criteria each time you filter?
not all the time

(2) will you advance filter the records manually all the time?
not all the time

(3) and is there a specific reason why you are wanting to select a row.
delete all results without deleting the heading

p45cal
02-10-2014, 09:32 AM
uktous, when you use the advanced filter, do you filter the list in place or copy to another location?
If you filter in place then you can use the likes of:
activesheet.range("_filterdatabase").offset(1).resize(1).select
and if you copy to another location:
activesheet.range("Extract").offset(1).resize(1).selectbut mancubus's questions will still need answering to get robust code.
edit post posting, since you posted within a minute of mine:
I'm going to assume:
1. You're filtering in-place.
2. The results are on the active sheet.
3. Some filtering has taken place. (I'll look to catering for no results found later.)


activesheet.range("_filterdatabase").resize(activesheet.range("_filterdatabase").rows.count-1).offset(1).delete

time passes…

catering for no filtered results:
Sub blah()
Dim DelRng As Range
On Error Resume Next
Set DelRng = ActiveSheet.Range("_filterdatabase").Resize(ActiveSheet.Range("_filterdatabase").Rows.Count - 1).Offset(1).SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not DelRng Is Nothing Then DelRng.Delete
End Sub

mancubus
02-10-2014, 10:16 AM
recommendations in this thread of yours did not provide a solution? http://www.vbaexpress.com/forum/showthread.php?48816-macro-to-delete-rows-in-result-of-advanced-filter

DILIPandey
02-10-2014, 10:23 PM
Hi uktous,

Just wanted to check if you tested my solution in post#2 ? thanks.


Regards,
DILIPandey

uktous
02-11-2014, 09:15 AM
Hi uktous,

Just wanted to check if you tested my solution in post#2 ? thanks.


Regards,
DILIPandey

tried all

only the first one on #5 is suitable for me

thanks !!!!!!

DILIPandey
02-12-2014, 12:35 AM
Okay thanks for the update :)



Regards,
DILIPandey