ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   AutoFilter results plus show next row (https://www.excelbanter.com/excel-programming/394981-autofilter-results-plus-show-next-row.html)

RAP

AutoFilter results plus show next row
 
Hello All:

I would like to take the results of an AutoFilter and have it show the
normal results plus the next row of each result.

Ex:
Unfiltered Page: Rows 1 - 20
Typical AutoFilter result: Rows 2, 10, 15
Desired AutoFilter result: Rows 2,3,10,11,15 & 16

Uber Thanks for any help or direction,
Randy

Tom Ogilvy

AutoFilter results plus show next row
 
Sub ShowRows()
Dim rng As Range, i As Long
Set rng = ActiveSheet.AutoFilter.Range
Set rng = rng.Offset(1, 0).Resize(rng.Rows.Count - 1, 1)
For i = rng(rng.Count).Row To rng.Row Step -1
If rng(i - rng.Row + 1).EntireRow.Hidden = False Then
rng(i - rng.Row + 2).EntireRow.Hidden = False
End If
Next
End Sub

--
regards,
Tom Ogilvy

"RAP" wrote:

Hello All:

I would like to take the results of an AutoFilter and have it show the
normal results plus the next row of each result.

Ex:
Unfiltered Page: Rows 1 - 20
Typical AutoFilter result: Rows 2, 10, 15
Desired AutoFilter result: Rows 2,3,10,11,15 & 16

Uber Thanks for any help or direction,
Randy


RAP

AutoFilter results plus show next row
 
Tom,

You are AWESOME !! Thank you so much. Works perfectly.

Randy



"Tom Ogilvy" wrote:

Sub ShowRows()
Dim rng As Range, i As Long
Set rng = ActiveSheet.AutoFilter.Range
Set rng = rng.Offset(1, 0).Resize(rng.Rows.Count - 1, 1)
For i = rng(rng.Count).Row To rng.Row Step -1
If rng(i - rng.Row + 1).EntireRow.Hidden = False Then
rng(i - rng.Row + 2).EntireRow.Hidden = False
End If
Next
End Sub

--
regards,
Tom Ogilvy

"RAP" wrote:

Hello All:

I would like to take the results of an AutoFilter and have it show the
normal results plus the next row of each result.

Ex:
Unfiltered Page: Rows 1 - 20
Typical AutoFilter result: Rows 2, 10, 15
Desired AutoFilter result: Rows 2,3,10,11,15 & 16

Uber Thanks for any help or direction,
Randy



All times are GMT +1. The time now is 07:10 PM.

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