Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Counting Selected/Highlighted Rows

Need to modify this maco to not count hidden rows. For example if seven rows
of ten rows in question are hidden, I need the macro to count only the three
visible on screen.

Also, if no rows were hidden, and all ten were selected (highlighted), the
macro should count ten.

In other words, it should count only what is selected/visible on screen.

Sub CountHighlightedRows()
MsgBox "Rows Selected: " & Selection.Rows.Count
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Counting Selected/Highlighted Rows

Not sure if I understand, but try this:

Sub fj()
Dim x As Long
x = Selection.SpecialCells(xlCellTypeVisible).Count
MsgBox x
End Sub


"Phil H" wrote in message
...
Need to modify this maco to not count hidden rows. For example if seven
rows
of ten rows in question are hidden, I need the macro to count only the
three
visible on screen.

Also, if no rows were hidden, and all ten were selected (highlighted), the
macro should count ten.

In other words, it should count only what is selected/visible on screen.

Sub CountHighlightedRows()
MsgBox "Rows Selected: " & Selection.Rows.Count
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Counting Selected/Highlighted Rows

I noticed an anomaly about using the xlVixible property to count the rows.
If you use the Rows.Count, it only counts to down to the first hidden row.
But if you only select one column and count the special cells visible
property, it give the correct count of rows not hidden.


"Phil H" wrote in message
...
Need to modify this maco to not count hidden rows. For example if seven
rows
of ten rows in question are hidden, I need the macro to count only the
three
visible on screen.

Also, if no rows were hidden, and all ten were selected (highlighted), the
macro should count ten.

In other words, it should count only what is selected/visible on screen.

Sub CountHighlightedRows()
MsgBox "Rows Selected: " & Selection.Rows.Count
End Sub



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Counting Selected/Highlighted Rows

This is sort of a gerry rig but it works and will do what you want.

Sub fl()
Dim x As Long
x = Selection.SpecialCells(xlCellTypeVisible) _
.Count / Selection.Columns.Count
MsgBox x
End Sub




"JLGWhiz" wrote in message
...
I noticed an anomaly about using the xlVixible property to count the rows.
If you use the Rows.Count, it only counts to down to the first hidden row.
But if you only select one column and count the special cells visible
property, it give the correct count of rows not hidden.


"Phil H" wrote in message
...
Need to modify this maco to not count hidden rows. For example if seven
rows
of ten rows in question are hidden, I need the macro to count only the
three
visible on screen.

Also, if no rows were hidden, and all ten were selected (highlighted),
the
macro should count ten.

In other words, it should count only what is selected/visible on screen.

Sub CountHighlightedRows()
MsgBox "Rows Selected: " & Selection.Rows.Count
End Sub





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default Counting Selected/Highlighted Rows

This will count all the visible rows in your selection. Hope this helps! If
so, let me know, click "YES" below.

Option Explicit

Sub CountHighlightedRows()

Dim rw As Range
Dim VisibleRows As Long

For Each rw In Selection.Rows
If rw.Hidden = False Then
VisibleRows = VisibleRows + 1
End If
Next rw

MsgBox "Rows Selected: " & VisibleRows, vbInformation

End Sub
--
Cheers,
Ryan


"Phil H" wrote:

Need to modify this maco to not count hidden rows. For example if seven rows
of ten rows in question are hidden, I need the macro to count only the three
visible on screen.

Also, if no rows were hidden, and all ten were selected (highlighted), the
macro should count ten.

In other words, it should count only what is selected/visible on screen.

Sub CountHighlightedRows()
MsgBox "Rows Selected: " & Selection.Rows.Count
End Sub



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Counting Selected/Highlighted Rows

Thanks for the help!

"Ryan H" wrote:

This will count all the visible rows in your selection. Hope this helps! If
so, let me know, click "YES" below.

Option Explicit

Sub CountHighlightedRows()

Dim rw As Range
Dim VisibleRows As Long

For Each rw In Selection.Rows
If rw.Hidden = False Then
VisibleRows = VisibleRows + 1
End If
Next rw

MsgBox "Rows Selected: " & VisibleRows, vbInformation

End Sub
--
Cheers,
Ryan


"Phil H" wrote:

Need to modify this maco to not count hidden rows. For example if seven rows
of ten rows in question are hidden, I need the macro to count only the three
visible on screen.

Also, if no rows were hidden, and all ten were selected (highlighted), the
macro should count ten.

In other words, it should count only what is selected/visible on screen.

Sub CountHighlightedRows()
MsgBox "Rows Selected: " & Selection.Rows.Count
End Sub

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Counting Selected/Highlighted Rows

Hi,

One way

Sub CountHighlightedRows()
For Each c In Selection.Rows
If c.RowHeight 0 Then
viz = viz + 1
End If
Next
MsgBox viz
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Phil H" wrote:

Need to modify this maco to not count hidden rows. For example if seven rows
of ten rows in question are hidden, I need the macro to count only the three
visible on screen.

Also, if no rows were hidden, and all ten were selected (highlighted), the
macro should count ten.

In other words, it should count only what is selected/visible on screen.

Sub CountHighlightedRows()
MsgBox "Rows Selected: " & Selection.Rows.Count
End Sub

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Counting Selected/Highlighted Rows

Thanks for the help!

"Mike H" wrote:

Hi,

One way

Sub CountHighlightedRows()
For Each c In Selection.Rows
If c.RowHeight 0 Then
viz = viz + 1
End If
Next
MsgBox viz
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Phil H" wrote:

Need to modify this maco to not count hidden rows. For example if seven rows
of ten rows in question are hidden, I need the macro to count only the three
visible on screen.

Also, if no rows were hidden, and all ten were selected (highlighted), the
macro should count ten.

In other words, it should count only what is selected/visible on screen.

Sub CountHighlightedRows()
MsgBox "Rows Selected: " & Selection.Rows.Count
End Sub

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
More than selected rows being highlighted RLD Excel Discussion (Misc queries) 2 March 17th 10 07:03 AM
Counting Highlighted Rows keiji kounoike Excel Programming 1 November 18th 09 04:01 PM
Counting Highlighted Rows Phil H[_2_] Excel Programming 1 November 17th 09 07:11 PM
I need currently selected Excel cell to be highlighted better Peggy Excel Discussion (Misc queries) 4 January 22nd 09 04:43 PM
make selected item highlighted in listview RB Smissaert Excel Programming 2 September 2nd 04 10:37 AM


All times are GMT +1. The time now is 02:29 PM.

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"