Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
DZ DZ is offline
external usenet poster
 
Posts: 29
Default Row number of filtered row

I need to get the row number of the second visible row in the current region.
The current region is filtered.

Example
If the current region starts at row 6, the second visible row is 28 because
the current region is filtered.

The following returns 7, because it not looking at visible rows only. I want
the return value to be 28, the second VISIBLE row.

Dim intRowNumber As Integer
intRowNumber = ActiveCell.CurrentRegion.Rows(2).Row

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Row number of filtered row

Hi,

Areas is what you want
Area 1 = heading
Area 2 = First visible row etc

so this returns the row number of the second visible row

Sub Macro2()
If ActiveSheet.FilterMode = True Then
x = ActiveSheet.UsedRange.SpecialCells _
(xlCellTypeVisible).Areas(3).Row
End If
End Sub

Mike

"DZ" wrote:

I need to get the row number of the second visible row in the current region.
The current region is filtered.

Example
If the current region starts at row 6, the second visible row is 28 because
the current region is filtered.

The following returns 7, because it not looking at visible rows only. I want
the return value to be 28, the second VISIBLE row.

Dim intRowNumber As Integer
intRowNumber = ActiveCell.CurrentRegion.Rows(2).Row

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
DZ DZ is offline
external usenet poster
 
Posts: 29
Default Row number of filtered row

Wonderful

Regards
Angelo DiBraccio

DZ
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Row number of filtered row

Are you trying to find the first visible detail row (not including the headers)?

Or are you trying to find the row number of the second visible detail row?

Option Explicit
Sub testme()

Dim WhatRow As Long
Dim VRng As Range

With ActiveSheet.AutoFilter.Range
Set VRng = .Resize(.Rows.Count - 1, 1).Offset(1, 0) _
.Cells.SpecialCells(xlCellTypeVisible)
End With

'first visible row excluding the headers
WhatRow = VRng.Cells(1).Row
MsgBox WhatRow

If VRng.Areas(1).Cells.Count 1 Then
WhatRow = VRng.Cells(1).Row + 1
Else
WhatRow = VRng.Areas(2).Cells(1).Row
End If

MsgBox WhatRow

End Sub


DZ wrote:

I need to get the row number of the second visible row in the current region.
The current region is filtered.

Example
If the current region starts at row 6, the second visible row is 28 because
the current region is filtered.

The following returns 7, because it not looking at visible rows only. I want
the return value to be 28, the second VISIBLE row.

Dim intRowNumber As Integer
intRowNumber = ActiveCell.CurrentRegion.Rows(2).Row

Thanks


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Row number of filtered row

And in case there aren't multiple areas -- or any visible details:

Option Explicit
Sub testme()

Dim WhatRow As Long
Dim VRng As Range

Set VRng = Nothing
On Error Resume Next
With ActiveSheet.AutoFilter.Range
Set VRng = .Resize(.Rows.Count - 1, 1).Offset(1, 0) _
.Cells.SpecialCells(xlCellTypeVisible)
End With
On Error GoTo 0

If VRng Is Nothing Then
MsgBox "no visible details"
Else
'first visible row excluding the headers
WhatRow = VRng.Cells(1).Row
MsgBox WhatRow

If VRng.Areas(1).Cells.Count 1 Then
WhatRow = VRng.Cells(1).Row + 1
Else
If VRng.Areas.Count 1 Then
WhatRow = VRng.Areas(2).Cells(1).Row
Else
WhatRow = -9999
End If
End If

MsgBox WhatRow
End If

End Sub


Dave Peterson wrote:

Are you trying to find the first visible detail row (not including the headers)?

Or are you trying to find the row number of the second visible detail row?

Option Explicit
Sub testme()

Dim WhatRow As Long
Dim VRng As Range

With ActiveSheet.AutoFilter.Range
Set VRng = .Resize(.Rows.Count - 1, 1).Offset(1, 0) _
.Cells.SpecialCells(xlCellTypeVisible)
End With

'first visible row excluding the headers
WhatRow = VRng.Cells(1).Row
MsgBox WhatRow

If VRng.Areas(1).Cells.Count 1 Then
WhatRow = VRng.Cells(1).Row + 1
Else
WhatRow = VRng.Areas(2).Cells(1).Row
End If

MsgBox WhatRow

End Sub

DZ wrote:

I need to get the row number of the second visible row in the current region.
The current region is filtered.

Example
If the current region starts at row 6, the second visible row is 28 because
the current region is filtered.

The following returns 7, because it not looking at visible rows only. I want
the return value to be 28, the second VISIBLE row.

Dim intRowNumber As Integer
intRowNumber = ActiveCell.CurrentRegion.Rows(2).Row

Thanks


--

Dave Peterson


--

Dave Peterson


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I 'count' the number of entrances in filtered cells? Mike Prentice Excel Worksheet Functions 2 September 19th 08 05:01 PM
How do I count the number of filtered rows 2D Rick Excel Worksheet Functions 2 January 7th 07 03:36 AM
How to number rows after data has been filtered? Maria Excel Discussion (Misc queries) 3 August 26th 05 02:57 PM
number missing when filtered Janice Lee via OfficeKB.com Excel Discussion (Misc queries) 2 April 11th 05 11:05 PM
Is there a limit to the number of rows that can be filtered W Paul Excel Worksheet Functions 3 March 8th 05 03:41 AM


All times are GMT +1. The time now is 12:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"